Security
Headlines
HeadlinesLatestCVEs

Headline

CVE-2023-4293: wpdm-premium-packages.php in wpdm-premium-packages/tags/5.7.4 – WordPress Plugin Repository

The Premium Packages - Sell Digital Products Securely plugin for WordPress is vulnerable to privilege escalation in versions up to, and including, 5.7.4 due to insufficient restriction on the ‘wpdmpp_update_profile’ function. This makes it possible for authenticated attackers, with minimal permissions such as a subscriber, to modify their user role by supplying the 'profile[role]' parameter during a profile update.

CVE
#mac#js#git#wordpress#php#auth#sap

1<?php2/**3 * Plugin Name: Premium Packages - Sell Digital Products Securely4 * Plugin URI: https://www.wpdownloadmanager.com/download/premium-package-complete-digital-store-solution/5 * Description: Complete solution for selling digital products securely and easily6 * Version: 5.7.47 * Author: WordPress Download Manager8 * Text Domain: wpdm-premium-packages9 * Author URI: https://www.wpdownloadmanager.com/10 */1112namespace WPDMPP;1314use WPDM\__\__;15use WPDM\__\__MailUI;16use WPDM\__\Email;17use WPDM\__\Messages;18use WPDM\__\Template;19use WPDM\__\Crypt;20use WPDM\__\FileSystem;21use WPDM\__\Session;22use WPDM\Package\FileList;23use WPDMPP\Libs\BillingInfo;24use WPDMPP\Libs\Cart;25use WPDMPP\Libs\CouponCodes;26use WPDMPP\Libs\Order;27use WPDMPP\Libs\Payment;28use WPDMPP\Libs\ShortCodes;29use WPDMPP\Libs\User;30use WPDMPP\Libs\Withdraws;3132if ( ! defined( ‘ABSPATH’ ) ) {33 exit;34}3536global $wpdmpp, $wpdmpp_settings;3738if ( ! class_exists( ‘WPDMPremiumPackage’ ) ):39 /**40 * @class WPDMPremiumPackage41 */4243 define( 'WPDMPP_VERSION’, ‘5.7.4’ );44 define( 'WPDMPP_BASE_DIR’, dirname( __FILE__ ) . ‘/’ );45 define( 'WPDMPP_BASE_URL’, plugins_url( ‘wpdm-premium-packages/’ ) );46 define( 'WPDMPP_TEXT_DOMAIN’, ‘wpdm-premium-packages’ );4748 if ( ! defined( ‘WPDMPP_MENU_ACCESS_CAP’ ) ) {49 define( 'WPDMPP_MENU_ACCESS_CAP’, ‘manage_categories’ );50 }51 if ( ! defined( ‘WPDMPP_ADMIN_CAP’ ) ) {52 define( 'WPDMPP_ADMIN_CAP’, ‘manage_categories’ );53 }5455 if ( ! defined( ‘WPDMPP_TPL_FALLBACK’ ) ) {56 define( 'WPDMPP_TPL_FALLBACK’, dirname( __FILE__ ) . ‘/templates/’ );57 }5859 if ( ! defined( ‘WPDMPP_TPL_DIR’ ) ) {60 define( 'WPDMPP_TPL_DIR’, dirname( __FILE__ ) . ‘/templates/’ );61 }6263 class WPDMPremiumPackage {6465 /**66 * @var Cart67 */68 public $cart;69 /**70 * @var Order71 */72 public $order;7374 /**75 * @var Withdraws76 */77 public $withdraws;7879 /**80 * @var Payment81 */82 public $payment;8384 /**85 * @var CouponCodes86 */87 public $couponCodes;8889 /**90 * @var ShortCodes91 */92 public $shortCodes;9394 function __construct() {95 global $wpdmpp_settings, $payment_methods;96 $wpdmpp_settings = maybe_unserialize( get_option( ‘_wpdmpp_settings’ ) );97 $payment_methods = [ 'TestPay’, 'Paypal’, 'Cash’, ‘Cheque’ ];9899 $this->init();100 $this->init_hooks();101102 }103104 private function init() {105 global $sap;106107 if ( function_exists( ‘get_option’ ) ) {108 $sap = ( get_option( ‘permalink_structure’ ) != ‘’ ) ? ‘?’ : '&’;109 }110111 $this->include_files();112113 }114115 private function init_hooks() {116117 register_activation_hook( __FILE__, [ '\WPDMPP\Libs\Installer’, ‘init’ ] );118119 add_action( 'wp’, [ $this, ‘download’ ], 1 );120121 add_action( 'wp_login’, [ new Cart(), ‘onUserLogin’ ], 10, 2 );122123 add_action( 'wpdm-package-form-left’, [ $this, ‘wpdmpp_meta_box_pricing’ ] );124 add_filter( 'wpdm_package_settings_tabs’, [ $this, ‘wpdmpp_meta_boxes’ ] );125 add_filter( 'add_wpdm_settings_tab’, [ $this, ‘settings_tab’ ] );126 add_filter( 'wpdm_privacy_settings_panel’, [ $this, ‘privacy_settings’ ] );127128 add_action( 'wpdm_template_editor_menu’, [ $this, ‘template_editor_menu’ ] );129 //add_action( 'wpdm_template_tag_row’, array( $this, ‘template_tag_row’ ));130131 add_action( 'init’, function () {132 $this->dbTables();133 $this->wpdmpp_languages();134 $this->clone_order();135 $this->invoice();136 $this->wpdmpp_process_guest_order();137 $this->paynow();138 $this->payment_notification();139 $this->comeplete_buynow_action();140 $this->wpdmpp_ajax_payfront();141 $this->anync_execute();142 $this->wpdmpp_update_profile();143 $this->freeDownload();144145 } );146147 /*148 add_action( 'init’, array( $this, ‘wpdmpp_languages’ ) );149 add_action( 'init’, array( $this, ‘invoice’ ) );150 add_action( 'init’, array( $this, ‘wpdmpp_process_guest_order’ ) );151 //add_action( 'init’, array( $this, ‘wpdmpp_download’ ), 1);152 add_action( 'init’, array( $this, ‘paynow’ ) );153 add_action( 'init’, array( $this, ‘payment_notification’ ) );154 add_action( 'init’, array( $this, ‘wpdmpp_ajax_payfront’ ) );155 add_action( 'init’, array( $this, ‘anync_execute’ ) );156 add_action( 'init’, array( $this, ‘wpdmpp_update_profile’ ) );157 add_action( 'init’, array( $this, ‘freeDownload’ ) );158 */159160 add_action( 'wpdm_login_form’, array( $this, ‘wpdmpp_invoice_field’ ) );161 add_action( 'wpdm_register_form’, array( $this, ‘wpdmpp_invoice_field’ ) );162 add_action( 'wp_login’, array( $this, ‘wpdmpp_associate_invoice’ ), 10, 2 );163 add_action( 'user_register’, array( $this, ‘wpdmpp_associate_invoice_signup’ ), 10, 1 );164165 add_action( 'wp_ajax_resolveorder’, array( $this, ‘wpdmpp_resolveorder’ ) );166167 add_action( 'wp_ajax_set_payment_method_for_order’, array( $this, ‘set_payment_method’ ) );168 add_action( 'wp_ajax_nopriv_set_payment_method_for_order’, array( $this, ‘set_payment_method’ ) );169170 add_action( 'wp_ajax_nopriv_gettax’, array( $this, ‘calculate_tax’ ) );171 add_action( 'wp_ajax_gettax’, array( $this, ‘calculate_tax’ ) );172173 add_action( 'wp_ajax_wpdmpp_cancel_subscription’, array( $this, ‘cancel_subscription’ ) );174175 add_action( 'wp_ajax_product_sales_overview’, array( $this, ‘wpdmpp_meta_box_sales_overview’ ) );176177 add_action( 'wp_ajax_nopriv_payment_options’, array( $this, ‘payment_options’ ) );178 add_action( 'wp_ajax_payment_options’, array( $this, ‘payment_options’ ) );179180 add_action( 'wp_ajax_wpdmpp_update_withdraw_status’, array( $this, ‘wpdmpp_update_withdraw_status’ ) );181182 add_action( 'wp_ajax_wpdmpp_expire_orders’, array( $this, ‘expire_orders’ ) );183184 add_action( 'wp_ajax_wpdmpp_email_payment_link’, array( $this, ‘email_payment_link’ ) );185186 add_action( 'wp_enqueue_scripts’, array( $this, ‘wpdmpp_enqueue_scripts’ ) );187188 add_action( 'admin_enqueue_scripts’, array( $this, ‘wpdmpp_admin_enqueue_scripts’ ) );189190 if ( is_admin() ) {191 add_action( 'wp_ajax_wpdmpp_save_settings’, array( $this, ‘saveSettings’ ) );192 add_action( 'wp_ajax_wpdmpp_toggle_auto_renew’, array( $this, ‘toggleAutoRenew’ ) );193 add_action( 'wp_ajax_wpdmpp_toggle_manual_renew’, array( $this, ‘toggleManualRenew’ ) );194 add_action( 'wp_ajax_wpdmpp_async_request’, array( $this, ‘wpdmpp_async_request’ ) );195 add_action( 'wp_loaded’, array( $this, ‘wpdmpp_hide_notices’ ) );196 }197198 if ( ! is_admin() ) {199 add_action( 'wpdm_login_form’, array( $this, ‘wpdmpp_guest_download_link’ ) );200 }201202 add_filter( 'wpdm_meta_box’, array( $this, ‘add_meta_boxes’ ) );203 add_filter( 'wpdm_user_dashboard_menu’, array( $this, ‘wpdmpp_user_dashboard_menu’ ) );204205 add_filter( 'wpdm_after_prepare_package_data’, array( $this, ‘fetchTemplateTag’ ) );206 add_filter( 'wdm_before_fetch_template’, array( $this, ‘fetchTemplateTag’ ) );207 add_filter( 'wpdm_download_link’, array( $this, ‘downloadLink’ ), 10, 2 );208 add_filter( 'wpdm_check_lock’, array( $this, ‘lockDownload’ ), 10, 2 );209 add_filter( 'wpdm_single_file_download_link’, array( $this, ‘hideSingleFileDownloadLink’ ), 10, 3 );210211 //add_action( 'activated_plugin’, array( $this, ‘pp_save_error’ ) );212213 add_action( 'init’, array( $this, ‘connect_wizard’ ) );214215 }216217 function dbTables() {218 global $wpdb;219 $wpdb->wpdmpp_orders = “{$wpdb->prefix}ahm_orders";220 $wpdb->wpdmpp_order_items = “{$wpdb->prefix}ahm_order_items";221 $wpdb->wpdmpp_coupons = “{$wpdb->prefix}ahm_coupons";222 $wpdb->wpdmpp_abandoned_orders = “{$wpdb->prefix}ahm_acr_emails";223 }224225226 function connect_wizard() {227 // Setup Wizard228 if ( ! empty( $_GET[‘page’] ) ) {229 switch ( $_GET[‘page’] ) {230 case ‘wpdmpp-setup’ :231 include_once( dirname( __FILE__ ) . ‘/includes/settings/wizard/class.SetupWizard.php’ );232 break;233 }234 }235 }236237 function wpdmpp_run_setup_wizard_notice() {238239 if ( get_option( ‘wpdmpp_setp_wizard_notice’ ) == ‘hide’ ) {240 return;241 }242 ?>243 <div class="notice notice-info is-dismissible w3eden">244 <p class="wpdmpp-notice"><?php _e( 'Thank you for installing Premium Package! You are almost ready to start selling.’, ‘wpdm-premium-packages’ ); ?>245 <a href="<?php echo esc_url( admin_url( ‘admin.php?page=wpdmpp-setup’ ) ); ?>"246 class="btn btn-sm btn-info"><?php _e( 'Run the Setup Wizard’, ‘wpdm-premium-packages’ ); ?></a>247 <a class="btn btn-sm btn-warning"248 href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wpdmpp-hide-notice’, ‘wizard’ ), 'wpdmpp_hide_notices_nonce’, ‘_wpdmpp_notice_nonce’ ) ); ?>"><?php _e( 'Skip setup’, ‘wpdm-premium-packages’ ); ?></a>249 </p>250 </div>251 <?php252 }253254 function wpdmpp_hide_notices() {255 if ( isset( $_GET[‘wpdmpp-hide-notice’] ) && isset( $_GET[‘_wpdmpp_notice_nonce’] ) ) {256 if ( ! wp_verify_nonce( $_GET[‘_wpdmpp_notice_nonce’], ‘wpdmpp_hide_notices_nonce’ ) ) {257 wp_die( __( 'Action failed. Please refresh the page and retry.’, ‘wpdm-premium-packages’ ) );258 }259260 if ( ! current_user_can( ‘manage_options’ ) ) {261 wp_die( __( 'Cheatin’ huh?’, ‘wpdm-premium-packages’ ) );262 }263264 $hide_notice = sanitize_text_field( $_GET[‘wpdmpp-hide-notice’] );265 if ( $hide_notice == ‘wizard’ ) {266 update_option( 'wpdmpp_setp_wizard_notice’, ‘hide’ );267 }268 }269 }270271 function pp_save_error() {272 file_put_contents( ABSPATH . 'pp-errors.txt’, ob_get_contents() );273 }274275 function wpdmpp_languages() {276 load_plugin_textdomain( 'wpdm-premium-packages’, false, dirname( plugin_basename( __FILE__ ) ) . ‘/languages/’ );277 }278279 function include_files() {280 include_once( dirname( __FILE__ ) . “/includes/libs/functions.php” );281 include_once( dirname( __FILE__ ) . “/includes/libs/Installer.php” );282 include_once( dirname( __FILE__ ) . “/includes/libs/User.php” );283 include_once( dirname( __FILE__ ) . “/includes/libs/LicenseManager.php” );284285 include_once( dirname( __FILE__ ) . “/includes/libs/Product.php” );286 include_once( dirname( __FILE__ ) . “/includes/libs/Cart.php” );287 $this->cart = new Cart();288289 include_once( dirname( __FILE__ ) . “/includes/libs/Order.php” );290 $this->order = new Order();291292 include_once( dirname( __FILE__ ) . “/includes/libs/Payment.php” );293 $this->payment = new Payment();294295 include_once( dirname( __FILE__ ) . “/includes/libs/CustomActions.php” );296 include_once( dirname( __FILE__ ) . “/includes/libs/CustomColumns.php” );297 include_once( dirname( __FILE__ ) . “/includes/libs/Currencies.php” );298 include_once( dirname( __FILE__ ) . “/includes/libs/BillingInfo.php” );299 include_once( dirname( __FILE__ ) . “/includes/libs/DashboardWidgets.php” );300 include_once( dirname( __FILE__ ) . “/includes/libs/OrderNoteTemplates.php” );301 include_once( dirname( __FILE__ ) . “/includes/libs/Withdraws.php” );302 $this->withdraws = new Withdraws();303304 include_once( dirname( __FILE__ ) . “/includes/libs/CouponCodes.php” );305 $this->couponCodes = new CouponCodes();306307 include_once( dirname( __FILE__ ) . “/includes/libs/ShortCodes.php” );308 $this->shortCodes = new ShortCodes();309310 include_once( dirname( __FILE__ ) . “/includes/libs/CronJobs.php” );311 include_once( dirname( __FILE__ ) . “/includes/libs/AbandonedOrderRecovery.php” );312 include_once( dirname( __FILE__ ) . “/includes/libs/cart-functions.php” );313 include_once( dirname( __FILE__ ) . “/includes/libs/hooks.php” );314315 include_once( dirname( __FILE__ ) . “/includes/menus/AdminMenus.php” );316317 // Cart Widget318 include_once( dirname( __FILE__ ) . “/includes/widgets/widget-cart.php” );319320 // Integrated payment mothods321 include_once( dirname( __FILE__ ) . “/includes/libs/payment-methods/Cash/Cash.php” );322 include_once( dirname( __FILE__ ) . “/includes/libs/payment-methods/Cheque/Cheque.php” );323 include_once( dirname( __FILE__ ) . “/includes/libs/payment-methods/Paypal/Paypal.php” );324 include_once( dirname( __FILE__ ) . “/includes/libs/payment-methods/TestPay/TestPay.php” );325 include_once( dirname( __FILE__ ) . “/includes/libs/SellerDashboard.php” );326327 }328329 function calculate_tax() {330331 $cartsubtotal = WPDMPP()->cart->cartTotal();332 $cartdiscount = WPDMPP()->cart->couponDiscount();333 $cartsubtotal -= $cartdiscount;334335 //$tax_total = wpdmpp_calculate_tax2();336337 $tax_total = WPDMPP()->cart->calculateTax( $cartsubtotal, wpdm_query_var( 'country’, ‘txt’ ), wpdm_query_var( 'state’, ‘txt’ ) );338339 $total_including_tax = $cartsubtotal + $tax_total;340341 if ( Session::get( ‘orderid’ ) ) {342 WPDMPP()->order->reCalculate( Session::get( ‘orderid’ ) );343 $customPayButton = “";344 if ( wpdm_query_var( 'payment_method’, ‘txt’ ) ) {345 $payment = new Payment();346 $payment->initiateProcessor( wpdm_query_var( 'payment_method’, ‘txt’ ) );347 if ( method_exists( $payment->Processor, ‘customPayButton’ ) ) {348 $customPayButton = $payment->Processor->customPayButton();349 }350 }351 }352353 $updates = [354 ‘tax’ => wpdmpp_price_format( $tax_total ),355 ‘total’ => wpdmpp_price_format( $total_including_tax ),356 ‘subtotal’ => $cartsubtotal,357 ‘dis’ => $cartdiscount,358 ‘order’ => Session::get( ‘orderid’ ),359 ‘payment_button’ => $customPayButton360 ];361362 wp_send_json( $updates );363 }364365366 /**367 * Metabox content for Pricing and other Premium Pckage Settings368 */369370 function wpdmpp_meta_box_sales_overview_loader() {371 ?>372 <div id="wpdmpp-sales-overview">373 <div style="padding: 50px 10px;text-align: center"><i374 class="fas fa-sync fa-spin"></i> <?php _e( 'Loading…’, ‘wpdm-premium-packages’ ); ?></div>375 </div>376 <script>377 jQuery(function ($) {378 $(‘#wpdmpp-sales-overview’).load(ajaxurl, {379 action: 'product_sales_overview’,380 post: <?php echo wpdm_query_var( ‘post’ ); ?>});381 });382 </script>383 <?php384 }385386 function wpdmpp_meta_box_sales_overview() {387 global $post;388 $data = Session::get( ‘sales_overview_html_’ . wpdm_query_var( ‘post’ ) );389 if ( $data ) {390 echo $data;391 die();392 }393 ob_start();394 include __DIR__ . '/includes/menus/templates/product-sales-overview.php’;395 $data = ob_get_clean();396 Session::set( ‘sales_overview_html_’ . wpdm_query_var( ‘post’ ), $data );397 echo $data;398 die();399 }400401402 function payment_options() {403 global $post;404 include \WPDM\__\Template::locate( 'checkout-cart/checkout.php’, dirname( __FILE__ ) . ‘/templates’ );405 die();406 }407408 function add_meta_boxes( $metaboxes ) {409 $pid = wpdm_query_var( ‘post’ );410 $price = wpdmpp_effective_price( $pid );411 if ( $price > 0 ) {412 $wpdmpp_metaboxes[‘sales-overview’] = array(413 ‘title’ => __( 'Sales Overview’, “wpdm-premium-packages” ),414 ‘callback’ => array(415 $this,416 'wpdmpp_meta_box_sales_overview_loader’417 ),418 ‘position’ => 'side’,419 ‘priority’ => 'core’420 );421 $metaboxes = $wpdmpp_metaboxes + $metaboxes;422 }423424 return $metaboxes;425 }426427 /**428 * Metabox content for Pricing and other Premium Pckage Settings429 */430 function wpdmpp_meta_box_pricing() {431 global $post;432 include Template::locate( 'metaboxes/wpdm-pp-settings.php’, WPDMPP_TPL_DIR );433 }434435 /**436 * @param $tabs437 *438 * @return mixed439 * @usage Adding Premium Package Settings Metabox by applying WPDM’s ‘wpdm_package_settings_tabs’ filter440 */441 function wpdmpp_meta_boxes( $tabs ) {442 if ( is_admin() ) {443 $tabs[‘pricing’] = array(444 ‘name’ => __( 'Pricing & Discounts’, “wpdm-premium-packages” ),445 ‘callback’ => array( $this, ‘wpdmpp_meta_box_pricing’ )446 );447 }448449 return $tabs;450 }451452453 /**454 * Premium Package Settings Page455 */456 function settings() {457 include( “includes/settings/settings.php” );458 }459460 function settings_tab( $tabs ) {461 $tabs[‘ppsettings’] = wpdm_create_settings_tab( 'ppsettings’, 'Premium Package’, array(462 $this,463 'settings’464 ), $icon = ‘fa-solid fa-basket-shopping’ );465466 return $tabs;467 }468469 /**470 * Generate Order Invoice op request471 */472 function invoice() {473 if ( isset( $_GET[‘id’] ) && $_GET[‘id’] != ‘’ && isset( $_GET[‘wpdminvoice’] ) ) {474 ob_start();475 wp_register_style( 'wpdm-front-bootstrap’, WPDM_BASE_URL . ‘assets/bootstrap/css/bootstrap.css’ );476 wp_register_style( 'font-awesome’, WPDM_BASE_URL . ‘assets/font-awesome/css/font-awesome.min.css’ );477 wp_register_style( 'wpdm-front’, WPDM_BASE_URL . ‘assets/css/front.css’ );478 wp_register_style( 'wpdmpp-invoice’, WPDMPP_BASE_URL . 'assets/css/invoice.css’, array(479 'wpdm-front-bootstrap’,480 'font-awesome’,481 'wpdm-front’482 ) );483 //include \WPDM\__\Template::locate(“wpdm-pp-invoice.php", WPDMPP_TPL_DIR);484 include \WPDM\__\Template::locate( “invoices/default/invoice.php", WPDMPP_TPL_DIR );485 $data = ob_get_clean();486487 $oid = sanitize_file_name( $_GET[‘id’] );488 echo $data;489 die();490 }491 }492493494 function wpdmpp_user_dashboard_menu( $menu ) {495 $menu = array_merge( array_splice( $menu, 0, 1 ), array(496 ‘purchases’ => array(497 ‘name’ => __( 'Purchases’, ‘wpdm-premium-packages’ ),498 ‘callback’ => array(499 $this,500 'wpdmpp_purchased_items’501 )502 )503 ), $menu );504505 return $menu;506 }507508 function wpdmpp_purchased_items( $params = array() ) {509 global $wpdb;510 $current_user = wp_get_current_user();511 $uid = $current_user->ID;512513 //$purchased_items = $wpdb->get_results(“select oi.*,o.currency, o.date as odate, o.order_status from {$wpdb->prefix}ahm_order_items oi,{$wpdb->prefix}ahm_orders o where o.order_id = oi.oid and o.uid = {$uid} and o.order_status IN ('Expired’, ‘Completed’) order by `date` desc”);514515 wpdmpp_expiry_check();516517 ob_start();518 if ( isset( $params[2] ) && $params[1] == ‘order’ ) {519 Order::userOrderDetails( $params[2] );520 } else {521 include_once wpdm_tpl_path( 'partials/resolve-order.php’, WPDMPP_TPL_DIR );522 include_once wpdm_tpl_path( 'partials/user-orders-list.php’, WPDMPP_TPL_DIR );523 }524 //else525 // include wpdm_tpl_path('user-dashboard/purchased-items.php’, WPDMPP_TPL_DIR);526527 return ob_get_clean();528 }529530531 /**532 * Process Guest Orders533 */534 function wpdmpp_process_guest_order() {535536 if ( wpdm_query_var( 'exitgo’, ‘int’ ) ) {537 Session::clear( ‘guest_order’ );538 $return = isset( $_SERVER[‘HTTP_REFERER’] ) ? $_SERVER[‘HTTP_REFERER’] : home_url( ‘/’ );539 wp_redirect( $return );540 die( ‘ok’ );541 }542543 if ( isset( $_POST[‘__wpdmpp_go’] ) ) {544545 check_ajax_referer( NONCE_KEY, ‘__wpdmpp_go_nonce’ );546547 //if( ! Session::get(‘guest_order_init’) ) { Session::set('guest_order_init’, uniqid(), 18000); die(‘nosess’); }548549 $orderid = sanitize_text_field( $_POST[‘__wpdmpp_go’][‘order’] );550 $orderemail = sanitize_email( $_POST[‘__wpdmpp_go’][‘email’] );551552 $o = new Order();553 $order = $o->getOrder( $orderid );554555 // No match for order id556 if ( ! is_object( $order ) || ! isset( $order->order_id ) || $order->order_id != $orderid ) {557 die( ‘noordr’ );558 }559560 // Found a match for order id561 $billing_info = unserialize( $order->billing_info );562 $billing_email = isset( $billing_info[‘order_email’] ) ? $billing_info[‘order_email’] : '’;563564 if ( is_email( $orderemail ) && $orderemail == $billing_email && $order->uid <= 0 ) {565 Session::set( 'guest_order’, $orderid, 18000 );566 Session::set( 'order_email’, $billing_email, 18000 );567 die( ‘success’ );568 }569570 // Order assigned to registered user, so no guest access, please login to access order571 if ( $order->uid > 0 ) {572 die( ‘nogues’ );573 }574575 die( ‘noordr’ );576 }577578 }579580581 /**582 * Save admin settings options583 */584 function saveSettings() {585 if ( wp_verify_nonce( wpdm_query_var( ‘__wpdms_nonce’ ), WPDMSET_NONCE_KEY ) && current_user_can( WPDMPP_ADMIN_CAP ) ) {586 $settings = $_POST[‘_wpdmpp_settings’];587 $settings = wpdm_sanitize_array( $settings );588 $settings = apply_filters( “wpdmpp_before_save_settings", $settings );589 update_option( '_wpdmpp_settings’, $settings );590 do_action( “wpdmpp_after_save_settings” );591 die( __( 'Settings Saved Successfully’, “wpdm-premium-packages” ) );592 }593 }594595596 static function authorize_masterkey() {597 if ( WPDM()->package->validateMasterKey( wpdm_query_var( ‘wpdmdl’ ), wpdm_query_var( ‘masterkey’ ) ) && (int) get_wpdmpp_option( ‘authorize_masterkey’ ) === 1 ) {598 return true;599 }600601 return false;602 }603604 function download() {605606 if ( wpdm_query_var( ‘wpdmppd’ ) !== ‘’ || wpdm_query_var( ‘wpdmppdl’ ) !== ‘’ ) {607608 $wpdmdd = wpdm_query_var( ‘wpdmppd’ ) !== ‘’ ? Crypt::decrypt( wpdm_query_var( ‘wpdmppd’ ), true ) : wpdmppdl_decode( wpdm_query_var( ‘wpdmppdl’ ) );609610 if ( ! is_array( $wpdmdd ) || ! isset( $wpdmdd[‘ID’], $wpdmdd[‘oid’] ) ) {611 Messages::error( __( “— Invalid download link —", “wpdm-premium-packages” ), 1 );612 }613614 $package = get_post( $wpdmdd[‘ID’], ARRAY_A );615616 $PID = (int) $wpdmdd[‘ID’]; // Product ID617 $OID = sanitize_text_field( $wpdmdd[‘oid’] ); // Order ID618 $domain = isset( $wpdmdd[‘domain’] ) ? sanitize_text_field( $wpdmdd[‘domain’] ) : '’;619620 $_REQUEST[‘oid’] = $OID;621622 /*623 if (wpdm_query_var(‘preact’) === ‘login’) {624 $user = wp_signon(array(‘user_login’ => wpdm_query_var(‘user’), ‘user_password’ => wpdm_query_var(‘pass’)));625 if (!$user->ID)626 \WPDM_Messages::error(__( “Login failed!", “wpdm-premium-packages” ), 1);627 else {628 wp_set_current_user($user->ID);629 Session::set('guest_order’, $OID, 18000);630 }631 }632633 if (wpdm_query_var(‘wpdm_access_token’) != ‘’) {634 $at = wpdm_query_var(‘wpdm_access_token’);635 if (!$at) die(json_encode(array(‘error’ => ‘Invalid Access Token!’)));636 $atx = explode(“x", $at);637 $uid = end($atx);638 $uid = (int)$uid;639 if (!$uid) die(json_encode(array(‘error’ => ‘Invalid Access Token!’)));640 $sat = get_user_meta($uid, '__wpdm_access_token’, true);641 if ($sat === ‘’) die(json_encode(array(‘error’ => ‘Invalid Access Token!’)));642 if ($sat === $at)643 wp_set_current_user($uid);644 else645 die(json_encode(array(‘error’ => ‘Invalid Access Token!’)));646 }*/647648649 global $wpdb;650 $current_user = wp_get_current_user();651 $settings = get_option( ‘_wpdmpp_settings’ );652653 $order = new Order();654 $odata = $order->getOrder( $OID );655 $items = array_keys( unserialize( $odata->cart_data ) );656 if ( $domain !== ‘’ && $domain === wpdm_query_var( ‘domain’ ) ) {657658 if ( ! user_can( $odata->uid, ‘manage_options’ ) ) {659 $current_user = get_user_by( 'id’, $odata->uid );660 wp_set_current_user( $odata->uid );661 wp_set_auth_cookie( $odata->uid );662 }663 if ( ! is_user_logged_in() ) {664 $odata->uid = 0;665 }666 $settings[‘guest_download’] = 1;667 Session::set( 'guest_order’, $OID, 18000 );668669 }670671672 $expire_date = $odata->expire_date > 0 ? $odata->expire_date : ( $odata->date + ( get_wpdmpp_option( 'order_validity_period’, 365 ) * 86400 ) );673674 if ( $odata->uid != $current_user->ID && ! Session::get( ‘guest_order’ ) ) {675 Messages::error( __( “Invalid Access!", “wpdm-premium-packages” ), 1 );676 }677 if ( $odata->order_status === ‘Expired’ || time() > $expire_date ) {678 Messages::error( __( “Sorry! Support and Update Access Period is Already Expired", “wpdm-premium-packages” ), 1 );679 }680681 $base_price = get_post_meta( $PID, '__wpdm_base_price’, true );682683684 $package[‘files’] = WPDM()->package->getFiles( $PID, true );685686 //wpdmdd($package);687 $cart = maybe_unserialize( $odata->cart_data );688689 $cfiles = array();690691 if ( isset( $cart[ $PID ][‘files’] ) && is_array( $cart[ $PID ][‘files’] ) && count( $cart[ $PID ][‘files’] ) > 0 ) {692 $files = $cart[ $PID ][‘files’];693 foreach ( $files as $fID ) {694 if ( $fID && isset( $package[‘files’][ $fID ] ) ) {695 $cfiles[ $fID ] = $package[‘files’][ $fID ];696 }697 }698 }699700 if ( count( $cfiles ) === 0 ) {701 $all_licenses = wpdmpp_get_licenses();702 $starter = array_keys( $all_licenses )[0];703 $_license = wpdm_valueof( $cart, “{$PID}/license/id” );704 if ( ! $_license ) {705 $_license = $starter;706 }707 $license_pack = get_post_meta( $PID, “__wpdm_license_pack", true );708 $license_pack = wpdm_valueof( $license_pack, $_license );709 if ( is_array( $license_pack ) ) {710 foreach ( $license_pack as $fID ) {711 $cfiles[ $fID ] = $package[‘files’][ $fID ];712 }713 }714 }715716 $package[‘individual_file_download’] = 1;717718 if ( $base_price == 0 && $PID > 0 ) {719 //for free items720 $package[‘access’] = array( ‘guest’ );721 include( WPDM_SRC_DIR . “wpdm-start-download.php” );722 }723724725 //Member’s Download726 if ( @in_array( $PID, $items ) && $OID != ‘’ && is_user_logged_in() && $current_user->ID == $odata->uid && $odata->order_status == ‘Completed’ ) {727 //for premium item728729 $order = new Order();730 $order->update( array( ‘download’ => 1 ), $OID );731732 if ( count( $cfiles ) > 0 && ! isset( $cfiles[ wpdm_query_var( ‘ind’ ) ] ) ) {733 if ( count( $cfiles ) > 1 ) {734 $zipped = \WPDM\__\FileSystem::zipFiles( $cfiles, $package[‘post_title’] . " " . $odata->order_id );735 \WPDM\__\FileSystem::downloadFile( $zipped, basename( $zipped ) );736 } else {737 $file = array_shift( $cfiles );738 if ( ! file_exists( $file ) ) {739 $file = WPDM()->fileSystem->locateFile( $file );740 }741 \WPDM\__\FileSystem::downloadFile( $file, basename( $file ) );742 }743744 die();745 } else {746 Session::set( '__wpdmpp_authorized_download’, 1 );747 $package[‘access’] = array( ‘guest’ );748 include( WPDM_SRC_DIR . “wpdm-start-download.php” );749 }750 }751 //wpdmdd($odata);752 //Guest’s Download753 if ( @in_array( $PID, $items )754 && $OID != '’755 && $odata->uid == 0756 && $odata->order_status == 'Completed’757 && isset( $settings[‘guest_download’] )758 && Session::get( ‘guest_order’ ) === $OID ) {759 Session::set( '__wpdmpp_authorized_download’, 1 );760 $package[‘access’] = array( ‘guest’ );761 $order = new Order();762 $order->Update( array( ‘download’ => 1 ), $OID );763 include( WPDM_SRC_DIR . “wpdm-start-download.php” );764765 }766767 Messages::error( __( “— Invalid download link —", “wpdm-premium-packages” ), 1 );768 }769770 if ( wpdm_query_var( ‘wpdmpp_file’ ) ) {771 $file = wpdm_query_var( ‘wpdmpp_file’ );772 $token = wpdm_query_var( ‘access_token’ );773 $_token = explode( “x", $token );774 $uid = end( $_token );775 $valid_token = get_user_meta( $uid, “__wpdm_access_token", true );776 if ( $token === $valid_token ) {777 $files = WPDMPP()->order->getPurchasedFiles( $uid );778 $file_path = wpdm_valueof( $files, $file );779 if ( $file_path !== ‘’ ) {780 WPDM()->fileSystem->downloadFile( $file_path, basename( $file_path ), 10240, 0 );781 die();782 } else {783 die( ‘Access Denied!’ );784 }785 } else {786 die( ‘Invalid Token!’ );787 }788 }789790 }791792 /**793 * Create new Order794 */795 function create_order() {796 $current_user = wp_get_current_user();797798 //If session already contains an order ID799 if ( Session::get( ‘orderid’ ) ) {800 $order = new Order();801 $order_info = $order->getOrder( Session::get( ‘orderid’ ) );802 // Check it the order ID in session is valid803 if ( is_object( $order_info ) && $order_info->order_id ) {804 // Check if the order is not completed yet805 if ( $order_info->order_status !== ‘Completed’ ) {806 $items = WPDMPP()->cart->getItems();807 $data = array(808 ‘cart_data’ => serialize( $items ),809 ‘items’ => serialize( array_keys( $items ) )810 );811 $order->reCalculate( $order_info->order_id );812 $order->updateOrderItems( $items, $order_info->order_id );813 $order->Update( $data, $order_info->order_id );814 //Set the incomplete order ID as the current order ID815 $order_id = $order_info->order_id;816 } else {817 // The order is already completed, so clear the session and create a new order818 Session::clear( ‘orderid’ );819 $order_id = WPDMPP()->order->open();820 }821 } else {822 // The order ID in session is not valid, so create a new order823 $order_id = WPDMPP()->order->open();824 }825826 } else {827 // No order ID in session, let’s create a new order828 $order_id = WPDMPP()->order->open();829 }830831 return $order_id;832 }833834 /**835 * Set payment method for order836 */837 function set_payment_method() {838 $current_user = wp_get_current_user();839 if(wpdm_query_var(‘wpdm_client’) !== ‘’)840 Session::deviceID(wpdm_query_var(‘wpdm_client’));841 //wpdmdd(WPDMPP()->cart->getItems());842 if ( wpdm_query_var( 'method’, ‘txt’ ) != ‘’ ) {843 //$order = new Order($_SESSION[‘orderid’]);844 //$order->set('payment_method’, wpdm_query_var('method’, ‘txt’));845 //$order->save();846 Session::set( 'payment_method’, wpdm_query_var( 'method’, ‘txt’ ) );847 $payment = new Payment();848 $payment->initiateProcessor( wpdm_query_var( 'method’, ‘txt’ ) );849850 ob_start();851 $billing_required = isset( $payment->Processor->billing ) ? (int) $payment->Processor->billing : 0;852 $billing = array();853 if ( is_user_logged_in() ) {854 $billing = BillingInfo::get( get_current_user_id() );855 }856 // If you payment menthod requires to fill a custom form during checkout857 if ( method_exists( $payment->Processor, “checkoutForm” ) ) {858 echo $payment->Processor->checkoutForm();859 } else {860 if ( get_wpdmpp_option( ‘billing_address’ ) == 1 || wpdmpp_tax_active() || $billing_required ) {861 // Ask Billing Address When Checkout862 include \WPDM\__\Template::locate( ‘checkout-cart/checkout-billing-info.php’, dirname( __FILE__ ) . ‘/templates’ . WPDM()->bsversion . “/", WPDMPP_TPL_FALLBACK );863 } else {864 // Ask only Name and Email When Checkout865 include \WPDM\__\Template::locate( ‘checkout-cart/checkout-name-email.php’, dirname( __FILE__ ) . ‘/templates’ . WPDM()->bsversion . “/", WPDMPP_TPL_FALLBACK );866 }867 }868 $billing_form = ob_get_clean();869870 if ( method_exists( $payment->Processor, ‘customPayButton’ ) ) {871 $cb = $payment->Processor->customPayButton();872 if ( $cb != ‘’ ) {873 wp_send_json( array( ‘button’ => 'custom’, ‘html’ => $cb, ‘billing_form’ => $billing_form ) );874 }875 }876 wp_send_json( array( ‘button’ => 'default’, ‘html’ => '’, ‘billing_form’ => $billing_form ) );877 }878 }879880881 /**882 * Saving payment method info from checkout process883 */884 function paynow() {885 if ( isset( $_REQUEST[‘task’] ) && $_REQUEST[‘task’] == “paynow” ) {886887 if ( wpdmpp_is_cart_empty() ) {888 die( '<div class="alert alert-danger” data-title="ERROR!">’ . __( 'Cart is Empty!’, ‘wpdmp-premium-package’ ) . ‘</div>’ );889 }890 if ( ! is_user_logged_in() && ( ! isset( $_POST[‘billing’][‘order_email’] ) || ! is_email( $_POST[‘billing’][‘order_email’] ) ) ) {891 die( '<div class="alert alert-danger” data-title="ERROR!">’ . __( 'Please enter order confirmation email!’, ‘wpdmp-premium-package’ ) . ‘</div>’ );892 }893894 $current_user = wp_get_current_user();895896 $order_id = $this->create_order();897898 $order = new Order();899 $order->update( [ ‘payment_method’ => wpdm_query_var( 'payment_method’, ‘txt’ ) ], $order_id );900901 //Update users billing info902 if ( is_user_logged_in() ) {903 $billing_info = wpdm_sanitize_array( $_POST[‘billing’] );904 $billing_info[‘order_email’] = sanitize_email( $_POST[‘billing’][‘order_email’] );905 $billing_info[‘email’] = sanitize_email( $_POST[‘billing’][‘order_email’] );906 $billing_info[‘phone’] = '’;907 $customer_billing_address = get_user_meta( $current_user->ID, 'user_billing_shipping’, true );908 if ( ! $customer_billing_address ) {909 update_user_meta( $current_user->ID, 'user_billing_shipping’, serialize( array( ‘billing’ => $billing_info ) ) );910 }911 }912 $this->place_order( $order_id );913 die();914 }915 }916917918 /**919 * Placing order from checkout process920 */921 function place_order( $order_id ) {922 //if(floatval(wpdmpp_get_cart_total()) <= 0 ) return;923 global $wpdb;924 $order = new Order();925 $order = $order->getOrder( $order_id );926 $order_total = $order->total;927 $tax = $order->tax;928929 $items = maybe_unserialize( $order->cart_data );930 //$cart_data = wpdmpp_get_cart_data();931932 if ( ! is_array( $items ) || count( $items ) == 0 ) {933 Messages::Error( __( “Cart is Empty!", “wpdm-premium-packages” ), 0 );934 die();935 }936937 $order_title = $order->title;938939 do_action( “wpdm_before_placing_order", $order_id );940941 // If order total is not 0 then go to payment gateway942 if ( $order_total > 0 ) {943944 $payment = new Payment();945 $payment->initiateProcessor( wpdm_query_var( 'payment_method’, ‘txt’ ) );946 $payment->Processor->OrderTitle = $order_title;947 $payment->Processor->InvoiceNo = $order_id;948 $payment->Processor->Custom = $order_id;949 $payment->Processor->Amount = number_format( $order_total, 2, “.", “” );950951 echo $payment->Processor->showPaymentForm( 1 );952953 if ( ! isset( $payment->Processor->EmptyCartOnPlaceOrder ) || $payment->Processor->EmptyCartOnPlaceOrder == true ) {954 wpdmpp_empty_cart();955 }956957 die();958959 } else {960 // if order total is 0 then empty cart and redirect to home961 Order::complete_order( $order_id );962 wpdmpp_empty_cart();963 wpdmpp_js_redirect( wpdmpp_orders_page( ‘id=’ . $order_id ) );964 }965 }966967 function clone_order() {968 if ( ! is_user_logged_in() ) {969 return;970 }971 $order = new Order( wpdm_query_var( 'clone_order’, ‘txt’ ) );972 if ( ! $order->order_id || (int) $order->uid !== get_current_user_id() ) {973 return;974 }975 WPDMPP()->cart->clear();976 //wpdmdd($order->cart_data);977 foreach ( $order->cart_data as $pid => $item ) {978 WPDMPP()->cart->addItem( $pid, wpdm_valueof( $item, ‘license/id’ ) );979 }980 wpdmpp_redirect( wpdmpp_cart_url() );981 //wpdmdd($cart_data);982 }983984 function is_auto_new_active() {985 global $wpdmpp_settings;986 $wpdmpp_settings[‘order_validity_period’] = (int) $wpdmpp_settings[‘order_validity_period’] > 0 ? (int) $wpdmpp_settings[‘order_validity_period’] : 365;987 if ( isset( $wpdmpp_settings[‘auto_renew’], $wpdmpp_settings[‘order_validity_period’] ) && $wpdmpp_settings[‘auto_renew’] == 1 && $wpdmpp_settings[‘order_validity_period’] > 0 ) {988 return true;989 }990991 return false;992 }993994 /**995 * Payment notification process/ IPN verification996 */997 function payment_notification() {998 if ( isset( $_REQUEST[‘action’] ) && $_REQUEST[‘action’] == “wpdmpp-payment-notification” ) {9991000 $payment_gateway_class = ‘WPDMPP\Libs\PaymentMethods\\’ . sanitize_text_field( $_REQUEST[‘class’] );1001 $payment_method = new $payment_gateway_class();10021003 //$payment_method = new $_REQUEST[‘class’]();10041005 if ( $payment_method->verifyNotification() ) {1006 do_action( “wpdmpp_payment_completed", $payment_method->InvoiceNo );1007 Order::complete_order( $payment_method->InvoiceNo, true, $payment_method );1008 do_action( “wpdm_after_checkout", $payment_method->InvoiceNo );1009 die( ‘OK’ );1010 }1011 die( “FAILED” );1012 }1013 }10141015 /**1016 * Payment notification process/ IPN verification1017 */1018 function comeplete_buynow_action() {1019 if ( wpdm_query_var( 'action’, ‘txt’ ) === “wpdmpp-complete-buynow” ) {10201021 $payment_gateway_class = ‘WPDMPP\Libs\PaymentMethods\\’ . sanitize_text_field( $_REQUEST[‘class’] );1022 $payment_method = new $payment_gateway_class();1023 $payment_method->completeBuyNow();1024 }1025 }10261027 function buy_now( $product_id, $license = '’, $extras = array() ) {1028 global $wpdmpp;1029 $wpdmpp->add_to_cart( $product_id );1030 $wpdmpp->create_order();1031 $order = new Order( Session::get( ‘orderid’ ) );10321033 wpdmpp_calculate_discount();1034 $order->updateOrderItems( wpdmpp_get_cart_data(), Session::get( ‘orderid’ ) );1035 $order_total = $order->calcOrderTotal( Session::get( ‘orderid’ ) );10361037 $tax = 0;10381039 foreach ( $pids as $pid ) {1040 $price = wpdmpp_effective_price( $pid );1041 $total += $price;1042 }104310441045 $cart_data[ $product_id ] = array(1046 ‘ID’ => $product_id,1047 ‘post_title’ => get_the_title( $product_id ),1048 ‘quantity’ => 1,1049 ‘variation’ => array(),1050 ‘variations’ => array(),1051 ‘files’ => array(),1052 ‘price’ => $price,1053 ‘prices’ => 0,1054 ‘discount_amount’ => 01055 );10561057 $o->newOrder( wpdm_query_var( ‘oid’ ), 'Custom Order’, $items, $total, 0, 'Completed’, 'Completed’, serialize( $cart_data ) );10581059 Order::updateOrderItems( $cart_data, wpdm_query_var( ‘oid’ ) );10601061 $subtotal = wpdmpp_get_cart_subtotal();1062 if ( wpdmpp_tax_active() && Session::get( ‘tax’ ) ) {1063 $tax = Session::get( ‘tax’ );1064 $order_total = $subtotal + $tax;1065 }1066 $cart_id = wpdmpp_cart_id();1067 $coupon = wpdmpp_get_cart_coupon();10681069 $grand_total = $order_total - (double) wpdm_valueof( $coupon, 'discount’, 0 );10701071 $grand_total = wpdmpp_price_format( $grand_total, false, false );1072 if ( is_user_logged_in() && $order->uid == 0 ) {1073 $order->set( 'uid’, get_current_user_id() );1074 }1075 $order->set( 'subtotal’, $subtotal );1076 $order->set( 'cart_discount’, 0 );1077 $order->set( 'payment_method’, ‘Paypal’ );1078 $order->set( 'coupon_discount’, $coupon[‘discount’] );1079 $order->set( 'coupon_code’, $coupon[‘code’] );1080 $order->set( 'tax’, $tax );1081 $order->set( 'order_notes’, ‘’ );1082 $order->set( 'total’, $grand_total );1083 $order->save();10841085 }10861087 /**1088 * Withdraw money from paypal notification1089 */1090 function wpdmpp_update_withdraw_status() {1091 if ( current_user_can( WPDMPP_ADMIN_CAP ) && wp_verify_nonce( wpdm_query_var( ‘__wpdmppwn_nonce’ ), NONCE_KEY ) ) {10921093 global $wpdb;1094 $wpdb->update(1095 “{$wpdb->prefix}ahm_withdraws",1096 array(1097 ‘status’ => 11098 ),1099 array( ‘id’ => sanitize_text_field( $_REQUEST[‘wid’] ) ),1100 array(1101 '%d’1102 ),1103 array( ‘%d’ )1104 );11051106 wp_send_json( array( ‘success’ => 1 ) );1107 die();11081109 }1110 }111111121113 /**1114 * Payment using ajax1115 */1116 function wpdmpp_ajax_payfront() {1117 if ( isset( $_POST[‘task’], $_POST[‘action’] ) && $_POST[‘task’] == “paymentfront” && $_POST[‘action’] == “wpdmpp_async_request” ) {1118 $data[‘order_id’] = sanitize_text_field( $_POST[‘order_id’] );1119 $data[‘payment_method’] = sanitize_text_field( $_POST[‘payment_method’] );1120 wpdmpp_pay_now( $data );1121 die();1122 }1123 }11241125 /**1126 * Dynamic function call using AJAX1127 */1128 function wpdmpp_async_request() {1129 $CustomActions = new \WPDMPP\Libs\CustomActions();1130 if ( method_exists( $CustomActions, $_POST[‘execute’] ) ) {1131 $method = sanitize_text_field( $_POST[‘execute’] );1132 echo $CustomActions->$method();1133 die();1134 } else {1135 die( “Function doesn’t exist” );1136 }1137 }11381139 /**1140 * Execute Custom Action1141 */1142 function anync_execute() {1143 $CustomActions = new \WPDMPP\Libs\CustomActions();1144 if ( isset( $_POST[‘action’] ) && $_POST[‘action’] == ‘wpdmpp_anync_exec’ ) {1145 if ( method_exists( $CustomActions, $_POST[‘execute’] ) ) {1146 $method = sanitize_text_field( $_POST[‘execute’] );1147 echo $CustomActions->$method();1148 die();1149 }1150 }11511152 }115311541155 /**1156 * Update User Profile1157 */1158 function wpdmpp_update_profile() {11591160 if ( is_user_logged_in() && wp_verify_nonce( wpdm_query_var( ‘__upnonce’ ), NONCE_KEY ) && isset( $_POST[‘profile’] ) ) {11611162 $userdata = $_POST[‘profile’];1163 $userdata[‘ID’] = get_current_user_id();1164 if ( $_POST[‘password’] == $_POST[‘cpassword’] ) {1165 wp_update_user( $userdata );1166 $userdata[‘user_pass’] = $_POST[‘password’];1167 update_user_meta( get_current_user_id(), 'payment_account’, sanitize_text_field( $_POST[‘payment_account’] ) );1168 update_user_meta( get_current_user_id(), 'phone’, sanitize_text_field( $_POST[‘phone’] ) );1169 Session::set( 'member_success’, __( “Profile Updated Successfully", “wpdm-premium-packages” ) );11701171 } else {1172 $merror = Session::get( ‘member_error’ );1173 $merror = is_array( $merror ) ? $merror : array();1174 $merror[] = __( “Confirm Password Not Matched. Profile Update Failed!", “wpdm-premium-packages” );1175 Session::set( 'member_error’, $merror );1176 }1177 update_user_meta( get_current_user_id(), 'user_billing_shipping’, serialize( wpdm_sanitize_array( $_POST[‘checkout’] ) ) );1178 $return = isset( $_SERVER[‘HTTP_REFERER’] ) ? $_SERVER[‘HTTP_REFERER’] : home_url( ‘/’ );1179 wpdmpp_redirect( $return );1180 die();1181 }11821183 }11841185 /**1186 * Load Scripts and Styles1187 *1188 * @param $hook1189 */1190 function wpdmpp_enqueue_scripts( $hook ) {11911192 $settings = get_option( ‘_wpdmpp_settings’ );1193 $cart_page = isset( $settings[‘page_id’] ) ? $settings[‘page_id’] : 0;11941195 wp_enqueue_script( 'wpdm-pp-js’, WPDMPP_BASE_URL . 'assets/js/wpdmpp-front.js’, array(1196 'jquery’,1197 'jquery-form’1198 ) );1199 if ( ! isset( $settings[‘disable_fron_end_css’] ) || (int) $settings[‘disable_fron_end_css’] === 0 ) {1200 wp_enqueue_style( 'wpdmpp-front’, WPDMPP_BASE_URL . 'assets/css/wpdmpp.css’, 999999 );1201 }12021203 //if((int)$cart_page === (int)get_the_ID()){1204 //wp_enqueue_script(‘jquery-validate’);1205 //}12061207 if ( get_the_ID() == wpdm_valueof( $settings, “orders_page_id” ) || ( isset( $settings[‘guest_order_page_id’] ) && get_the_ID() == $settings[‘guest_order_page_id’] ) ) {1208 wp_enqueue_script( ‘thickbox’ );1209 wp_enqueue_style( ‘thickbox’ );1210 wp_enqueue_script( ‘media-upload’ );1211 wp_enqueue_media();1212 }1213 }12141215 function wpdmpp_admin_enqueue_scripts( $hook ) {1216 if ( get_post_type() == ‘wpdmpro’ || strstr( $hook, ‘dmpro_page’ ) ) {1217 wp_enqueue_script( ‘jquery’ );1218 wp_enqueue_script( ‘jquery-form’ );1219 wp_enqueue_script( ‘jquery-ui-core’ );1220 wp_enqueue_script( ‘jquery-ui-datepicker’ );1221 wp_enqueue_script( ‘jquery-ui-accordion’ );12221223 wp_enqueue_style( 'wpdmpp-admin’, WPDMPP_BASE_URL . ‘assets/css/wpdmpp-admin.min.css’ );1224 wp_enqueue_script( 'wpdmpp-admin-js’, WPDMPP_BASE_URL . 'assets/js/wpdmpp-admin.js’, array( ‘jquery’ ) );12251226 // Load Download Manager Scripts1227 //wp_enqueue_style('wpdm-admin-bootstrap’, WPDM_BASE_URL . ‘assets/bootstrap3/css/bootstrap.css’);1228 //wp_enqueue_script('wpdm-admin-bootstrap’, WPDM_BASE_URL . 'assets/bootstrap3/js/bootstrap.min.js’, array(‘jquery’));1229 wp_enqueue_script( 'jquery-validate’, WPDM_BASE_URL . 'assets/js/jquery.validate.min.js’, array( ‘jquery’ ) );1230 //wp_enqueue_script('wpdm-bootstrap-select’, WPDM_BASE_URL.’assets/js/bootstrap-select.min.js’, array(‘jquery’, ‘wpdm-admin-bootstrap’));1231 //wp_enqueue_style(‘wpdm-bootstrap-select’, WPDM_BASE_URL.’assets/css/bootstrap-select.min.css’);1232 }1233 }12341235 /**1236 * Check if a Package is premium1237 *1238 * @param $pid1239 *1240 * @return bool1241 */1242 public static function isPremium( $pid ) {1243 $price = wpdmpp_product_price( $pid );1244 if ( $price > 0 ) {1245 return true;1246 }12471248 return false;1249 }12501251 /**1252 * @usage Check if user purchased an item1253 *1254 * @param $pid1255 * @param int $uid1256 *1257 * @return bool|string|null1258 */12591260 public static function hasPurchased( $pid, $uid = 0 ) {1261 global $wpdb;1262 $current_user = wp_get_current_user();1263 if ( ! is_user_logged_in() && ! $uid ) {1264 return false;1265 }1266 $uid = $uid ? $uid : $current_user->ID;1267 $orderid = $wpdb->get_var( "select o.order_id from {$wpdb->prefix}ahm_orders o, {$wpdb->prefix}ahm_order_items oi where uid=’{$uid}’ and o.order_id = oi.oid and oi.pid = {$pid} and order_status=’Completed’” );12681269 return $orderid;1270 }12711272 /**1273 * Generate Download URL1274 *1275 * @param $id Package ID1276 *1277 * @return string1278 */1279 static function customerDownloadLink( $id ) {1280 global $wpdmpp_settings;1281 $downloadurl = self::customerDownloadURL( $id );1282 $label = get_post_meta( $id, ‘__wpdm_link_label’, true );1283 $label = $label ? $label : __( ‘Download’, ‘wpdm-premium-packages’ );1284 if ( $downloadurl ) {1285 return "<a class=’btn btn-success btn-lg’ href=’{$downloadurl}’>{$label}</a>";1286 }12871288 return isset( $wpdmpp_settings[‘cdl_fallback’] ) && $wpdmpp_settings[‘cdl_fallback’] == ‘1’ ? wpdmpp_add_to_cart_html( $id ) : “";1289 }12901291 /**1292 * @param $pid1293 * @param null $orderid1294 * @param array $extras1295 *1296 * @return string1297 */1298 static function customerDownloadURL( $pid, $orderid = null, $extras = array() ) {1299 if ( ! $orderid ) {1300 $orderid = self::hasPurchased( $pid );1301 }1302 if ( ! $orderid ) {1303 return null;1304 }1305 $params = is_array( $extras ) ? $extras : array();1306 $params[‘ID’] = $pid;1307 $params[‘oid’] = $orderid;1308 if ( defined( ‘WPDMPPD_PERMALINK’ ) && WPDMPPD_PERMALINK === true ) {1309 $wpdmppd = wpdmppdl_encode( $params );13101311 return home_url( “/?wpdmppdl={$wpdmppd}” );1312 } else {1313 $wpdmppd = Crypt::encrypt( $params );13141315 return home_url( “/?wpdmppd={$wpdmppd}” );1316 }1317 }13181319 function hideSingleFileDownloadLink( $link, $fileID, $package ) {1320 if ( ! isset( $package[‘ID’] ) ) {1321 return $link;1322 }1323 $effective_price = wpdmpp_effective_price( $package[‘ID’] );1324 if ( $effective_price > 0 ) {1325 $link = ‘’;1326 }13271328 return $link;1329 }13301331 public static function hasFreeFile( $id = null ) {1332 if ( ! $id ) {1333 $id = get_the_ID();1334 }1335 $fd = maybe_unserialize( get_post_meta( $id, ‘__wpdm_free_downloads’, true ) );1336 if ( is_array( $fd ) && count( $fd ) > 0 && $fd[0] != ‘’ ) {1337 return $fd;1338 }13391340 return false;1341 }13421343 function freeDownload() {1344 if ( isset( $_GET[‘wpdmdlfree’] ) ) {1345 $id = (int) $_GET[‘wpdmdlfree’];1346 $freefiles = self::hasFreeFile( $id );13471348 if ( ! $freefiles ) {1349 wp_die( ‘No free file found!’ );1350 }1351 $pack = array( ‘ID’ => $id );1352 //do_action("wpdm_onstart_download", $pack);13531354 if ( count( $freefiles ) > 1 ) {1355 foreach ( $freefiles as &$freefile ) {1356 $freefile = str_replace( site_url( ‘/’ ), ABSPATH, $freefile );1357 }1358 $zipped = \WPDM\__\FileSystem::zipFiles( $freefiles, get_the_title( $id ) );1359 \WPDM\__\FileSystem::downloadFile( $zipped, basename( $zipped ) );1360 } else {1361 header( "location: " . array_pop( $freefiles ) );1362 }1363 die();1364 }1365 }13661367 /**1368 * @param $id1369 * @param $link_label1370 * @param string $class1371 *1372 * @return string1373 */1374 static function free_download_button( $id, $link_label, $class = ‘btn btn-lg btn-info btn-block’ ) {1375 return “<a href=’” . home_url( ‘/?wpdmdlfree=’ . $id ) . "’ class=’{$class}’ >” . $link_label . "</a>";1376 }137713781379 function downloadLink( $link, $package ) {1380 $effective_price = wpdmpp_effective_price( $package[‘ID’] );1381 if ( $effective_price > 0 ) {13821383 if ( wpdm_valueof( $package, ‘template_type’ ) === ‘link’ ) {1384 return wpdmpp_waytocart( $package ) . print_r( $package, 1 );1385 } else {1386 return wpdmpp_add_to_cart_html( $package[‘ID’] );1387 }1388 }13891390 return $link;1391 }139213931394 /**1395 * @param $vars1396 *1397 * @return mixed1398 */1399 function fetchTemplateTag( $vars ) {1400 global $wpdb, $wpdmpp_settings;14011402 $effective_price = wpdmpp_effective_price( $vars[‘ID’] );1403 $vars[‘effective_price’] = $effective_price;1404 $vars[‘currency’] = wpdmpp_currency_sign();1405 $vars[‘currency_code’] = wpdmpp_currency_code();1406 $vars[‘free_download_btn’] = "";14071408 if ( ! isset( $vars[‘post_author’] ) ) {1409 $product = (array) get_post( $vars[‘ID’] );1410 $vars += $product;1411 }1412 $store = get_user_meta( $vars[‘post_author’], ‘__wpdm_public_profile’, true );1413 if ( ! isset( $vars[‘author_name’] ) ) {1414 $author = get_userdata( $vars[‘post_author’] );1415 if ( $author ) {1416 $vars[‘author_name’] = $author->display_name;1417 }1418 }1419 $vars[‘store_name’] = isset( $store[‘title’] ) ? $store[‘title’] : $vars[‘author_name’];1420 $vars[‘store_intro’] = isset( $store[‘intro’] ) ? $store[‘intro’] : ‘’;1421 $vars[‘store_logo’] = isset( $store[‘logo’] ) && $store[‘logo’] != ‘’ ? "<img class=’store-logo’ src=’{$store[‘logo’]}’ alt=’{$vars[‘store_name’]}’ />” : get_avatar( $vars[‘post_author’], 512 );14221423 if ( $effective_price > 0 && self::hasFreeFile( $vars[‘ID’] ) ) {1424 $vars[‘free_download_btn’] = self::free_download_button( $vars[‘ID’], $vars[‘link_label’] );1425 $vars[‘free_download_url’] = home_url( ‘/?wpdmdlfree=’ . $vars[‘ID’] );1426 } else {1427 $vars[‘free_download_btn’] = $vars[‘free_download_url’] = '’;1428 }1429 if ( $effective_price > 0 || get_post_meta( $vars[‘ID’], '__wpdm_pay_as_you_want’, true ) == 1 ) {1430 $vars[‘base_price’] = wpdmpp_price_format( get_post_meta( $vars[‘ID’], '__wpdm_base_price’, true ) );1431 $vars[‘sales_price’] = wpdmpp_price_format( get_post_meta( $vars[‘ID’], '__wpdm_sales_price’, true ) );1432 $vars[‘addtocart_url’] = wpdmpp_cart_page( array( ‘addtocart’ => $vars[‘ID’] ) );1433 $vars[‘addtocart_link’] = wpdmpp_waytocart( $vars );1434 $vars[‘addtocart_button’] = $vars[‘addtocart_link’];1435 $vars[‘addtocart_form’] = wpdmpp_add_to_cart_html( $vars[‘ID’] );1436 $vars[‘customer_download_link’] = $this->customerDownloadLink( $vars[‘ID’] );1437 if ( isset( $vars[‘__template_type’] ) && $vars[‘__template_type’] == ‘link’ ) {1438 $vars[‘download_link’] = $vars[‘addtocart_button’];1439 } else {1440 $vars[‘download_link’] = $vars[‘addtocart_form’];1441 }1442 $vars[‘download_link_extended’] = $vars[‘addtocart_form’];1443 $vars[‘download_link_popup’] = $vars[‘addtocart_button’];1444 $vars[‘price_range’] = wpdmpp_price_range( $vars[‘ID’] );1445 } else {1446 $vars[‘addtocart_url’] = $vars[‘download_url’];1447 $vars[‘addtocart_link’] = $vars[‘download_link’];1448 $vars[‘addtocart_form’] = $vars[‘download_link’];1449 $vars[‘customer_download_link’] = $vars[‘download_link’];1450 $vars[‘price_range’] = wpdmpp_currency_sign() . '0.00’;1451 $vars[‘sales_price’] = $vars[‘base_price’] = '’;1452 }14531454 return $vars;1455 }14561457 function template_editor_menu() {1458 ?>1459 <li class="dropdown">1460 <a href="#” id="droppp” role="button” class="dropdown-toggle"1461 data-toggle="dropdown"><?php _e( 'Premium Package’, ‘wpdm-premium-packages’ ); ?><b1462 class="caret"></b></a>1463 <ul class="dropdown-menu” role="menu” aria-labelledby="droppp">1464 <li role="presentation"><a role="menuitem” tabindex=”-1"1465 href="#[addtocart_url]“><?php _e( 'AddToCart URL’, ‘wpdm-premium-packages’ ); ?></a>1466 </li>1467 <li role="presentation"><a role="menuitem” tabindex=”-1"1468 href="#[addtocart_link]“><?php _e( 'AddToCart Link’, ‘wpdm-premium-packages’ ); ?></a>1469 </li>1470 <li role="presentation"><a role="menuitem” tabindex=”-1"1471 href="#[addtocart_form]“><?php _e( 'AddToCart Form’, ‘wpdm-premium-packages’ ); ?></a>1472 </li>1473 <li role="presentation"><a role="menuitem” tabindex=”-1"1474 href="#[customer_download_link]“><?php _e( 'Customer Download Link’, ‘wpdm-premium-packages’ ); ?></a>1475 </li>1476 <li role="presentation"><a role="menuitem” tabindex=”-1"1477 href="#[free_download_url]“><?php _e( 'Free Download Button’, ‘wpdm-premium-packages’ ); ?></a>1478 </li>1479 <li role="presentation"><a role="menuitem” tabindex=”-1"1480 href="#[free_download_btn]“><?php _e( 'Free Download URL’, ‘wpdm-premium-packages’ ); ?></a>1481 </li>1482 <li role="presentation"><a role="menuitem” tabindex=”-1"1483 href="#[price_range]“><?php _e( 'Price Range’, ‘wpdm-premium-packages’ ); ?></a>1484 </li>1485 <li role="presentation"><a role="menuitem” tabindex=”-1"1486 href="#[premium_file_list]“><?php _e( 'File List Price’, ‘wpdm-premium-packages’ ); ?></a>1487 </li>1488 <li role="presentation"><a role="menuitem” tabindex=”-1"1489 href="#[effective_price]“><?php _e( 'Effective Item Price’, ‘wpdm-premium-packages’ ); ?></a>1490 </li>1491 <li role="presentation"><a role="menuitem” tabindex=”-1"1492 href="#[currency_code]“><?php _e( 'Currency Code’, ‘wpdm-premium-packages’ ); ?></a>1493 </li>1494 <li role="presentation"><a role="menuitem” tabindex=”-1"1495 href="#[currency]“><?php _e( 'Currency Sign’, ‘wpdm-premium-packages’ ); ?></a>1496 </li>1497 <li role="presentation"><a role="menuitem” tabindex=”-1"1498 href="#[base_price]“><?php _e( 'Base Price’, ‘wpdm-premium-packages’ ); ?></a>1499 </li>1500 <li role="presentation"><a role="menuitem” tabindex=”-1"1501 href="#[sales_price]“><?php _e( 'Sales Price’, ‘wpdm-premium-packages’ ); ?></a>1502 </li>1503 <li role="presentation"><a role="menuitem” tabindex=”-1"1504 href="#[store_name]“><?php _e( 'Shop Name’, ‘wpdm-premium-packages’ ); ?></a>1505 </li>1506 <li role="presentation"><a role="menuitem” tabindex=”-1"1507 href="#[store_intro]“><?php _e( 'Shop Intro’, ‘wpdm-premium-packages’ ); ?></a>1508 </li>1509 <li role="presentation"><a role="menuitem” tabindex=”-1"1510 href="#[store_logo]“><?php _e( 'Shop Logo’, ‘wpdm-premium-packages’ ); ?></a>1511 </li>1512 </ul>1513 </li>15141515 <?php1516 }15171518 function template_tag_row() {1519 ?>1520 <tr>1521 <td><input type="text” readonly="readonly” class="form-control" onclick="this.select()“1522 value=”[addtocart_url]" style="font-size:10px;width: 120px;text-align: center;"></td>1523 <td>- <?php echo __( 'AddToCart URL for a package’, ‘wpdm-premium-packages’ ); ?></td>1524 </tr>1525 <tr>1526 <td><input type="text" readonly="readonly" class="form-control" onclick="this.select()“1527 value=”[addtocart_link]" style="font-size:10px;width: 120px;text-align: center;"></td>1528 <td>- <?php echo __( 'AddToCart Link for a package’, ‘wpdm-premium-packages’ ); ?></td>1529 </tr>1530 <tr>1531 <td><input type="text" readonly="readonly" class="form-control" onclick="this.select()“1532 value=”[addtocart_form]" style="font-size:10px;width: 120px;text-align: center;"></td>1533 <td>- <?php echo __( 'AddToCart Form’, ‘wpdm-premium-packages’ ); ?></td>1534 </tr>1535 <tr>1536 <td><input type="text" readonly="readonly" class="form-control" onclick="this.select()“1537 value=”[customer_download_link]" style="font-size:10px;width: 120px;text-align: center;">1538 </td>1539 <td>- <?php echo __( ‘Customer Download Link’, ‘wpdm-premium-packages’ ); ?></td>1540 </tr>1541 <tr>1542 <td><input type="text" readonly="readonly" class="form-control" onclick="this.select()“1543 value=”[free_download_btn]" style="font-size:10px;width: 120px;text-align: center;"></td>1544 <td>- <?php echo __( ‘Free Download Button’, ‘wpdm-premium-packages’ ); ?></td>1545 </tr>1546 <tr>1547 <td><input type="text" readonly="readonly" class="form-control" onclick="this.select()“1548 value=”[free_download_url]" style="font-size:10px;width: 120px;text-align: center;"></td>1549 <td>- <?php echo __( ‘Free Download URL’, ‘wpdm-premium-packages’ ); ?></td>1550 </tr>1551 <?php1552 }15531554 /**1555 * Required for guest checkout1556 */1557 function wpdmpp_invoice_field() {1558 $oid = Session::get( “orderid” );1559 if ( $oid ) {1560 echo "<input type=’hidden’ name=’invoice’ value=’" . sanitize_text_field( $oid ) . "’ />";1561 }1562 }15631564 /**1565 * Link Guest Order when user logging in1566 *1567 * @param $user_login1568 * @param $user1569 */1570 function wpdmpp_associate_invoice( $user_login, $user ) {1571 if ( isset( $_POST[‘invoice’] ) ) {1572 $order = new Order();1573 $orderdata = $order->getOrder( sanitize_text_field( $_POST[‘invoice’] ) );1574 if ( $orderdata && intval( $orderdata->uid ) == 0 ) {1575 Order::Update( array( ‘uid’ => $user->ID ), sanitize_text_field( $_POST[‘invoice’] ) );1576 }1577 }1578 }15791580 /**1581 * Link Guest Order when user Signing Up1582 *1583 * @param $user_id1584 */1585 function wpdmpp_associate_invoice_signup( $user_id ) {1586 if ( isset( $_POST[‘invoice’] ) ) {1587 $order = new Order();1588 $orderdata = $order->getOrder( sanitize_text_field( $_POST[‘invoice’] ) );1589 if ( $orderdata && intval( $orderdata->uid ) == 0 ) {1590 Order::Update( array( ‘uid’ => $user_id ), sanitize_text_field( $_POST[‘invoice’] ) );1591 User::addCustomer( $user_id );1592 }1593 }1594 }15951596 /**1597 * Resolve unassigned Order1598 */1599 function wpdmpp_resolveorder() {1600 $current_user = wp_get_current_user();1601 $order = new Order();1602 $data = $order->getOrder( sanitize_text_field( $_REQUEST[‘orderid’] ) );1603 if ( ! $data ) {1604 die( “Order not found!” );1605 }1606 if ( $data->uid != 0 ) {1607 if ( $data->uid == $current_user->ID ) {1608 die( “The order is already linked to your account!” );1609 } else {1610 die( “The order is already linked to an account!” );1611 }1612 }1613 Order::Update( array( ‘uid’ => $current_user->ID ), $data->order_id );1614 User::addCustomer();1615 die( “ok” );1616 }16171618 /**1619 * Filter for locked Downloads1620 *1621 * @param $lock1622 * @param $id1623 *1624 * @return string1625 */1626 function lockDownload( $lock, $id ) {1627 $effective_price = wpdmpp_effective_price( $id );1628 if ( intval( $effective_price ) > 0 ) {1629 $lock = 'locked’;1630 }16311632 return $lock;1633 }16341635 function wpdmpp_guest_download_link() {1636 global $wp_query;16371638 if ( isset( $wp_query->query_vars[‘udb_page’] ) && strstr( $wp_query->query_vars[‘udb_page’], ‘purchases’ ) && wpdmpp_guest_order_page() ):1639 include_once \WPDM\__\Template::locate( “partials/guest_order_page_link.php", WPDMPP_TPL_DIR );1640 endif;1641 }16421643 function toggleAutoRenew() {1644 if ( isset( $_REQUEST[‘__arnonce’] ) && wp_verify_nonce( $_REQUEST[‘__arnonce’], NONCE_KEY ) ) {1645 $order = new Order( sanitize_text_field( $_REQUEST[‘orderid’] ) );1646 $renew = (int)$order->auto_renew === 1 ? 0 : 1;1647 $order->set( 'auto_renew’, $renew );1648 $order->save();1649 $dt = array( ‘renew’ => $renew );1650 $pm = “\WPDMPP\Libs\PaymentMethods\\” . $order->payment_method;1651 if ( class_exists( $pm ) && $renew == 0 ) {1652 $pm = new $pm();1653 $dt[‘payment_method’] = $order->payment_method;1654 if ( method_exists( $pm, ‘cancelSubscription’ ) ) {1655 $pm->cancelSubscription( $order->order_id );1656 $dt[‘canceled’] = 1;1657 }16581659 }1660 header( “Content-type: application/json” );1661 echo json_encode( $dt );1662 } else {1663 echo json_encode( array( ‘error’ => ‘Session Expired!’ ) );1664 }1665 die();1666 }16671668 function toggleManualRenew() {1669 if ( isset( $_REQUEST[‘__mrnonce’] ) && wp_verify_nonce( $_REQUEST[‘__mrnonce’], NONCE_KEY ) ) {1670 $orderID = sanitize_text_field( $_REQUEST[‘orderid’] );1671 $mrenew = (int) Order::getMeta( $orderID, ‘manual_renew’ );1672 $mrenew = $mrenew ? 0 : 1;1673 Order::updateMeta( $orderID, 'manual_renew’, $mrenew );1674 wp_send_json( [ ‘success’ => true, ‘mrenew’ => $mrenew ] );1675 } else {1676 wp_send_json( [ ‘error’ => ‘Session Expired!’ ] );1677 }1678 die();1679 }16801681 function cancel_subscription() {1682 if ( isset( $_REQUEST[‘__cansub’] ) && wp_verify_nonce( $_REQUEST[‘__cansub’], NONCE_KEY ) ) {1683 $order = new Order( sanitize_text_field( $_REQUEST[‘orderid’] ) );1684 $renew = 0;1685 $order->set( ‘auto_renew’, $renew );1686 $order->save();1687 $dt = array( ‘renew’ => $renew );1688 $pm = “\WPDMPP\Libs\PaymentMethods\\” . $order->payment_method;1689 if ( class_exists( $pm ) ) {1690 $pm = new $pm();1691 $dt[‘payment_method’] = $order->payment_method;1692 if ( method_exists( $pm, ‘cancelSubscription’ ) ) {1693 $pm->cancelSubscription( $order->order_id );1694 $dt[‘canceled’] = 1;1695 }16961697 }1698 $message = "Subscription Canceled For Order# {$order->oid}<br/><a style=’background-color:#19B999;border:none;border-radius:3px;color:#ffffff !important;display:inline-block;font-size:14px;font-weight:bold;outline:none!important;padding:5px 15px;margin:10px auto;text-decoration:none;’ href=’” . admin_url( “/edit.php?post_type=wpdmpro&page=orders&task=vieworder&id={$order->oid}” ) . “’>View Order</a>";1699 $params = array(1700 ‘subject’ => “Subscription Canceled: Order# {$order->oid}",1701 ‘to_email’ => get_option( “admin_email” ),1702 ‘message’ => $message1703 );1704 \WPDM\__\Email::send( 'default’, $params );1705 header( “Content-type: application/json” );1706 echo json_encode( $dt );1707 die();1708 } else {1709 echo json_encode( array( ‘error’ => ‘Session Expired!’ ) );1710 }1711 die();1712 }171317141715 function privacy_settings() {1716 ?>1717 <div class="panel panel-default">1718 <div class="panel-heading"><?php _e( 'Checkout Settings’, ‘wpdm-premium-packages’ ); ?></div>1719 <div class="panel-body">17201721 <div class="form-group">1722 <input type="hidden” value="0” name="__wpdm_checkout_privacy"/>1723 <label><input style="margin: 0 10px 0 0"1724 type="checkbox" <?php checked( get_option( ‘__wpdm_checkout_privacy’ ), 1 ); ?>1725 value="1"1726 name="__wpdm_checkout_privacy"><?php _e( 'Must agree with privacy policy before checkout’, ‘wpdm-premium-packages’ ); ?>1727 </label><br/>1728 <em><?php _e( 'User must agree with privacy policy before they purchase any item’, ‘wpdm-premium-packages’ ); ?></em>1729 </div>1730 <div class="form-group">1731 <label><?php _e( 'Privacy policy label:’, ‘wpdm-premium-packages’ ); ?></label>1732 <input type="text" class="form-control"1733 value="<?php echo get_option( ‘__wpdm_checkout_privacy_label’ ); ?>"1734 name="__wpdm_checkout_privacy_label">1735 </div>17361737 </div>1738 </div>17391740 <?php1741 }174217431744 function expire_orders() {1745 if ( current_user_can( WPDMPP_ADMIN_CAP ) ) {1746 $oids = $_REQUEST[‘oids’];1747 foreach ( $oids as $oid ) {1748 Order::expireOrder( $oid );1749 }1750 }1751 die( ‘Done!’ );1752 }17531754 function email_payment_link() {1755 $price = __::query_var( 'price’, ‘double’ );1756 $name = __::query_var( 'name’, ‘txt’ );1757 $desc = __::query_var( 'desc’, ‘txt’ );1758 $plink = home_url( “/??addtocart=dynamic&price={$price}&name={$name}&desc={$desc}&recurring=0” );1759 $paymentinfo = “<small style=’color: #aaaaaa’>” . __( 'Reason’, WPDMPP_TEXT_DOMAIN ) . “</small><br/>{$name}<hr style=’border-top:0;border-bottom: 1px solid #dddddd;box-shadow: none’/><small style=’color: #aaaaaa’>” . __( 'Description’, WPDMPP_TEXT_DOMAIN ) . “</small><br/>{$desc}<hr style=’border-top:0;border-bottom: 1px solid #dddddd;box-shadow: none’/><small style=’color: #aaaaaa’>” . __( ‘Payment Amount’, WPDMPP_TEXT_DOMAIN ) . “</small><h3 style=’margin: 0’>” . wpdmpp_price_format( $price ) . “</h3>";1760 $msg = __MailUI::panel( __( 'Payment request’, WPDMPP_TEXT_DOMAIN ), [ wpautop( __::query_var( 'msg’, ‘kses’ ) ) ] ) . “<div style=’height: 15px;display: block’></div>";1761 $msg .= __MailUI::panel( __( 'Payment details’, WPDMPP_TEXT_DOMAIN ), [ $paymentinfo ] ) . '<a class="button” style="display:block;text-align:center” href="’ . $plink . ‘">’ . __( 'Proceed to payment’, WPDMPP_TEXT_DOMAIN ) . '</a>’;1762 $params = [1763 ‘to_email’ => __::query_var( 'emails’, ‘txt’ ),1764 ‘subject’ => sprintf( __( 'Payment request from %s’, WPDMPP_TEXT_DOMAIN ), get_option( ‘blogname’ ) ),1765 ‘message’ => $msg1766 ];1767 Email::send( “default", $params );1768 wp_send_json( [ ‘success’ => true ] );1769 }17701771 function active_payment_gateways() {1772 global $payment_methods;1773 $settings = maybe_unserialize( get_option( ‘_wpdmpp_settings’ ) );1774 $payment_methods = apply_filters( 'payment_method’, $payment_methods );1775 $payment_methods = isset( $settings[‘pmorders’] ) && count( $settings[‘pmorders’] ) == count( $payment_methods ) ? $settings[‘pmorders’] : $payment_methods;17761777 return $payment_methods;1778 }177917801781 }17821783endif;17841785if ( defined( ‘WPDM_VERSION’ ) )1786 $wpdmpp = new WPDMPremiumPackage();1787else {1788 class RequireWPDM {17891790 function __construct() {1791 add_action( 'admin_notices’, array( $this, ‘check’ ) );1792 }17931794 function check() {1795 $class = 'notice notice-error’;1796 $message = ‘<strong>Missing a required plugin!</strong><br/>Please install/activate <a href="’ . admin_url( ‘/plugin-install.php?tab=favorites&user=codename065’ ) . '” target="_blank"><strong>WordPress Download Manager</strong></a> to use WPDM - Premium Packages plugin’;1797 printf( '<div class="%1$s"><p>%2$s</p></div>’, esc_attr( $class ), ( $message ) );1798 }1799 }18001801 new RequireWPDM();1802}180318041805

CVE: Latest News

CVE-2023-50976: Transactions API Authorization by oleiman · Pull Request #14969 · redpanda-data/redpanda
CVE-2023-6905
CVE-2023-6903
CVE-2023-6904
CVE-2023-3907