HEX
Server: nginx/1.24.0
System: Linux VM-8-5-opencloudos 6.6.47-12.oc9.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Sep 24 16:15:42 CST 2024 x86_64
User: www (1000)
PHP: 8.0.26
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/aiwellbore.com/wp-content/plugins/restrict-content/core/includes/invoice-functions.php
<?php
/**
 * Invoice Functions
 *
 * @package     Restrict Content Pro
 * @subpackage  Invoice Functions
 * @copyright   Copyright (c) 2017, Restrict Content Pro
 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
 */

/**
 * Generate URL to view / download an invoice
 *
 * @param int $payment_id ID of the payment to get the invoice for.
 *
 * @since 2.6
 * @return string URL to view/download invoice.
*/
function rcp_get_invoice_url( $payment_id = 0 ) {

	if ( empty( $payment_id ) ) {
		return false;
	}

	return add_query_arg( array( 'payment_id' => urlencode( $payment_id ), 'rcp-action' => 'download_invoice' ), home_url() );
}

/**
 * Trigger invoice download
 *
 * @uses rcp_generate_invoice()
 *
 * @return void
 */
function rcp_trigger_invoice_download() {

	if( ! isset( $_GET['rcp-action'] ) || 'download_invoice' != $_GET['rcp-action'] ) {
		return;
	}

	$payment_id = absint( $_GET['payment_id'] );

	rcp_generate_invoice( $payment_id );

}
add_action( 'init', 'rcp_trigger_invoice_download' );

/**
 * Generate Invoice
 *
 * @param int $payment_id ID of the payment to generate the invoice for.
 *
 * @since 2.6
 * @return void
*/
function rcp_generate_invoice( $payment_id = 0 ) {

	global $rcp_options, $rcp_payment, $rcp_member;

	if ( empty( $payment_id ) ) {
		return;
	}

	$payments_db  = new RCP_Payments;
	$payment      = $payments_db->get_payment( $payment_id );

	if( ! $payment ) {
		wp_die( __( 'This payment record does not exist', 'rcp' ) );
	}

	if( $payment->user_id != get_current_user_id() && ! current_user_can( 'rcp_manage_payments' ) ) {
		wp_die( __( 'You do not have permission to download this invoice', 'rcp' ) );
	}

	$rcp_payment = $payment;
	$rcp_member = new RCP_Member( $payment->user_id );

	rcp_get_template_part( 'invoice' );

	die(); // Stop the rest of the page from processsing and being sent to the browser
}