403Webshell
Server IP : 195.130.67.5  /  Your IP : 216.73.217.154
Web Server : Microsoft-IIS/10.0
System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586
User : IUSR ( 0)
PHP Version : 7.4.19
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/Old Sites/moke/components/com_imageads/models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : C:/Old Sites/moke/components/com_imageads/models/notify.php
<?php
/**
 * @version $Id: notify.php
 * @package ImageAds
 * @author Andrey Sokolnikov <aasfalcon@gmail.com>
 * @copyright (C) 2011 Emergination, LLC. All rights reserved.
 * @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
 */

// no direct access
defined('_JEXEC') or die('Restricted access');

// PayPal helper class
require_once IA_PATH_SITE.DS.'classes'.DS.'paypal.php';

/**
 * IPN Notify model
 *
 * @package ImageAds
 */
class imageadsModelNotify extends JModel
{
	/**
	 * Process PayPal IPN
	 * 
	 * The errors should be logged via error_log() because there is no user
	 * output for notifications.
	 * 
	 * @return bool True if payment is processed 
	 */
	function processIPN()
	{
		// collect IPN data and store in DB
		$validate_result = IA_PAYPAL_VALIDATE_IPN_ERROR;
		$ipn = &imageadsPayPal::validateIPN($validate_result);
		
		// log error if there was validation failture
		if (IA_PAYPAL_VALIDATE_IPN_VERIFIED != $validate_result) {
			error_log(sprintf(JText::_('COM_IMAGEADS_IPN_ERROR'),
				JText::_('COM_IMAGEADS_IPN_VALIDATION_ERROR')));
				
			if (!IA_IGNORE_HTTP_ERRORS) {
				return false;
			}
		}
		
		// assign IPN variables to local variables
		$payment_status		= $ipn->getValue('payment_status');
		$payment_amount		= $ipn->getValue('mc_gross');
		$payment_currency	= $ipn->getValue('mc_currency');
		$receiver_email		= $ipn->getValue('receiver_email');
		$txn_id				= $ipn->getValue('txn_id');
		$txn_type			= $ipn->getValue('txn_type');
		$ad_id				= $ipn->getValue('item_number');
		
		// consider only Completed payments
		if ("subscr_payment" != $txn_type || 'Completed' != $payment_status) {
			return false;
		}
		
		// check that txn_id has not been previously processed
		$sql = "SELECT p.id, p.txn_id"
			."\nFROM #__image_ads_payments AS p"
			."\nWHERE p.ad_id=".(int)$ad_id
			;
		$this->_db->setQuery($sql);
		$payment = $this->_db->loadObject();
		
		if ($this->_db->getErrorNum()) {
			error_log(sprintf(JText::_('COM_IMAGEADS_IPN_ERROR'),
				$this->_db->getErrorMsg()));
			return false;
		}
		
		$is_processed = $payment && $payment->txn_id == $txn_id;
		 
		if ($is_processed) {
			return false; // already processed IPN
		}
		
		// check that receiver_email is your Primary PayPal email
		$params = JComponentHelper::getParams(IA_OPTION);
		
		if ($params->get('paypal_email') != $receiver_email) {
			return false; // wrong email address
		}
		
		// save transaction
		if ($txn_id) {
			JTable::addIncludePath(IA_PATH_ADMIN.DS.'tables');
			$payments_table = JTable::getInstance('Payments', 'imageadsTable');
			
			if ($payment) {
				$payments_table->load($payment->id);
			}
			
			$payments_table->ad_id = (int)$ad_id;
			$payments_table->txn_id = $txn_id;
			$payments_table->ipn = $ipn->toString();
			
			if (!$payments_table->check() || !$payments_table->store()) {
				error_log(sprintf(JText::_('COM_IMAGEADS_IPN_ERROR'),
					$payments_table->getError()));
				return false;
			}
		}
		
		// check that payment_amount/payment_currency are correct
		if ($params->get('paypal_currency_code') != $payment_currency
			|| $payment_amount < $params->get('ad_minimum_price'))
		{
			return false; // currency or amount is wrong, save payment data, but not process it 
		}  
		
		// update image ads record last paid date
		$now = new JDate();
		$sql = "UPDATE #__image_ads"
			."\nSET last_paid_at=".$this->_db->quote($now->toMySql())
			."\nWHERE id=".(int)$ad_id
			;
		$this->_db->setQuery($sql);
		
		if (!$this->_db->query()) {
			error_log(sprintf(JText::_('COM_IMAGEADS_IPN_ERROR'),
				$this->_db->getErrorMsg()));
			return false;
		}

		return true;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit