AnonSec Shell
Server IP : 54.36.91.62  /  Your IP : 216.73.217.94
Web Server : Apache
System : Linux webm013.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64
User : coopiak ( 151928)
PHP Version : 8.3.23
Disable Function : _dyuweyrj4,_dyuweyrj4r,dl
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/coopiak/amisdesseniors-fr/voscatalogues/plugins/djcatalog2payment/tpay/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/coopiak/amisdesseniors-fr/voscatalogues/plugins/djcatalog2payment/tpay/tpay.php
<?php
/**
 * @package DJ-Catalog2
 * @copyright Copyright (C) DJ-Extensions.com, All rights reserved.
 * @license http://www.gnu.org/licenses GNU/GPL
 * @author url: http://dj-extensions.com
 * @author email contact@dj-extensions.com
 */

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

jimport('joomla.plugin.plugin');

class plgDjcatalog2paymentTpay extends JPlugin
{

    protected $currency;

    public function __construct(&$subject, $config = array())
    {
        parent::__construct($subject, $config);
        $cparams = JComponentHelper::getParams('com_djcatalog2');
        $this->currency = $cparams->get('cart_currency', 'USD');
        $this->debug = $this->params->get('debug', 0);
        $this->loadLanguage();
    }

    protected function isAllowed($plgInfo, $type = 'djcatalog2payment')
    {
        return (bool)($plgInfo->plugin == $this->_name && $this->_type == $type);
    }

    public function onContentPrepareForm($form, $data)
    {
        if ($form->getName() != 'com_djcatalog2.payment') {
            return;
        }

        $plugin = '';

        if (!empty($data) && !empty($data->plugin)) {
            $plugin = $data->plugin;
        } else {
            $jform = JFactory::getApplication()->input->get('jform', array(), 'array');
            if (!empty($jform) && isset($jform['plugin'])) {
                $plugin = $jform['plugin'];
            }
        }

        if ($plugin != $this->_name) {
            return true;
        }

        return $form->loadFile(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'configuration.xml', false);
    }

    public function onDJC2BeforeSaveOrder($context, $table, $isNew, $plgInfo)
    {
        if ($context != 'com_djcatalog2.checkout.payment' || !$this->isAllowed($plgInfo)) {
            return;
        }
    }

    public function onDJC2AfterSaveOrder($context, $table, $isNew, $plgInfo)
    {
        if ($context != 'com_djcatalog2.checkout.payment' || !$this->isAllowed($plgInfo)) {
            return;
        }
    }

    public function onDJC2CheckoutDetailsDisplay($context, $plgInfo)
    {
        if ($context != 'com_djcatalog2.checkout.payment' || !$this->isAllowed($plgInfo)) {
            return;
        }

        $html = '';
        if (trim(strip_tags($plgInfo->description)) != '') {
            $html = '<h4>' . $plgInfo->name . '</h4>';
            $html .= $plgInfo->description;
        }

        return $html;
    }

    public function onDJC2OrderDetailsDisplay($context, $order, $plgInfo)
    {
        if ($context != 'com_djcatalog2.order.payment' || !$this->isAllowed($plgInfo)) {
            return;
        }

        $app = JFactory::getApplication();

        $message = '';
        if ($app->input->get('view') == 'order' && $app->input->get('error')) {
            $message = JText::_('PLG_DJCATALOG2PAYMENT_TPAY_ERROR_TEXT');
        } else if ($app->input->get('success') == '1') {
            $message = JText::_('PLG_DJCATALOG2PAYMENT_TPAY_RETURN_TEXT');
        }

        if ($order->status != 'A' && $order->status != 'N') {
            return;
        }

        $paymentUrl = JRoute::_('index.php?option=com_djcatalog2&task=paymentProcess&oid=' . $order->id . '&plg=' . $plgInfo->plugin . '&plgid=' . $plgInfo->id);

        $html = '<div class="tpayinfo">';

        if ($message) {
            $html .= '<p class="tpayalert">' . $message . '</p>';
        } else if ($app->input->get('finished') == '1') {
            $app->redirect(JRoute::_('index.php?option=com_djcatalog2&task=paymentProcess&oid=' . $order->id . '&plg=' . $plgInfo->plugin . '&plgid=' . $plgInfo->id, false), 302);
        }


        $html .= '<p class="tpaymessage">';
        $html .= JText::_('PLG_DJCATALOG2PAYMENT_TPAY_INFO_TEXT');
        $html .= '</p>';
        $html .= '<p class="tpaybutton">';
        $html .= '<a href="' . $paymentUrl . '" class="tpaybtn btn btn-primary">' . JText::_('PLG_DJCATALOG2PAYMENT_TPAY_BTN') . '</a>';
        $html .= '</p>';
        $html .= '</div>';

        return $html;
    }

    public function onDJC2PaymentProcess($context, $order, $plgInfo)
    {
        if ($context != 'com_djcatalog2.order.payment' || !$this->isAllowed($plgInfo)) {
            return;
        }

        $tpay_id = $plgInfo->params->get('tpay_id');
        $tpay_auth_key = $plgInfo->params->get('tpay_auth_key');
        $environment = $plgInfo->params->get('environment');

        if (empty($tpay_id) || empty($tpay_auth_key)) {
            throw new Exception(JText::_('PLG_DJCATALOG2PAYMENT_TPAY_ERROR_MISSING_PARAMS'), 400);
        }

        $app = JFactory::getApplication();
        $websiteName = $app->get('sitename', JURI::base());

        $return = JRoute::_(DJCatalogHelperRoute::getOrderRoute($order->id) . '&success=1', false, (JUri::getInstance()->isSSL() ? 1 : -1));
        $cancel_return = JRoute::_(DJCatalogHelperRoute::getOrderRoute($order->id) . '&error=1', false, (JUri::getInstance()->isSSL() ? 1 : -1));
        $notify_url = JRoute::_(DJCatalogHelperRoute::getCategoryRoute(0) . '&task=paymentResponse&plg=' . $plgInfo->plugin . '&plgid=' . $plgInfo->id . '&oid=' . $order->id, false, (JUri::getInstance()->isSSL() ? 1 : -1));

        $cancel_return .= '&ts=' . time();
        $notify_url .= '&ts=' . time();
        $return .= '&ts=' . time();


        $amount = number_format($order->grand_total, 2, ".", "");
        $description = JText::sprintf('PLG_DJCATALOG2PAYMENT_TPAY_ORDER_NAME', $order->id);
        $crc = $order->id;
        $md5sum = md5($tpay_id . $amount . $crc . $tpay_auth_key);

        $email = $order->email;
        $name = $order->firstname;
        $lastname = $order->lastname;
        $address = $order->address;
        $city = $order->city;
        $zipcode = $order->postcode;
        $phone = $order->phone;


        $html = '<!doctype html><html lang="en-US"><head><meta charset="UTF-8"><title>' . JText::_('COM_DJCATALOG2_PAYMENT_REDIRECTION') . '</title></head>';
        $html .= '<body><div style="margin: auto; text-align: center;">';
        $html .= '<p>' . JText::_('COM_DJCATALOG2_PAYMENT_REDIRECTION') . '</p>';
        $html .= '<form method="POST" action="https://secure.tpay.com" name="tpayForm">';

        $html .= '<input type="hidden" name="id" value="' . $tpay_id . '" />';
        $html .= '<input type="hidden" name="kwota" value="' . $amount . '" />';
        $html .= '<input type="hidden" name="opis" value="' . $description . '" />';
        $html .= '<input type="hidden" name="crc" value="' . $crc . '" />';
        $html .= '<input type="hidden" name="md5sum" value="' . $md5sum . '" />';
        $html .= '<input type="hidden" name="online" value="' . $environment . '" />';
        $html .= '<input type="hidden" name="result_url" value="' . $notify_url . '" />';
        $html .= '<input type="hidden" name="return_url" value="' . $return . '" />';
        $html .= '<input type="hidden" name="return_error_url" value="' . $cancel_return . '" />';
        $html .= '<input type="hidden" name="email" value="' . $email . '" />';
        $html .= '<input type="hidden" name="imie" value="' . $name . '" />';
        $html .= '<input type="hidden" name="nazwisko" value="' . $lastname . '" />';
        $html .= '<input type="hidden" name="adres" value="' . $address . '" />';
        $html .= '<input type="hidden" name="miasto" value="' . $city . '" />';
        $html .= '<input type="hidden" name="kod" value="' . $zipcode . '" />';
        $html .= '<input type="hidden" name="telefon" value="' . $phone . '" />';
        $html .= '<input type="hidden" id="channel"  name="kanal" value=" ">';

        $html .= '<noscript><input type="submit"  value="' . JText::_('COM_DJCATALOG2_PAYMENT_REDIRECTION_BUTTON') . '" /></noscript>';
        //$html .= '<input type="submit"  value="' . JText::_('COM_DJCATALOG2_PAYMENT_REDIRECTION_BUTTON') . '" />';
        $html .= '</form></div>';

        $html .= ' <script type="text/javascript">';
        $html.= ' document.tpayForm.submit();';
        $html .= ' </script></body></html>';

        echo $html;
        $app->close();
    }


    public function onDJC2PaymentDiscover($context, $plgInfo)
    {
        if ($context != 'com_djcatalog2.order.payment' || !$this->isAllowed($plgInfo)) {
            return;
        }
        $this->log('[onDJC2PaymentDiscover] ' . $plgInfo->plugin);
        $this->log('[onDJC2PaymentDiscover] ' . print_r($_POST, true));

        $app = JFactory::getApplication();

        return $app->input->getInt('oid');
    }


    public function onDJC2PaymentResponse($context, $order, $model, $plgInfo)
    {
        if ($context != 'com_djcatalog2.order.payment' || !$this->isAllowed($plgInfo)) {
            return;
        }

        $this->log('[onDJC2PaymentResponse] ' . $plgInfo->plugin);
        $app = JFactory::getApplication();
		$amount = number_format($order->grand_total, 2, ".", "");

        file_put_contents(JPATH_ROOT . '/log.txt', $_POST['tr_amount'] . ' ' . $amount);


        $allowed_ips = array(
            '195.149.229.109',
            '148.251.96.163',
            '178.32.201.77',
            '46.248.167.59',
            '46.29.19.106'
        );

        if (
        	in_array($_SERVER['REMOTE_ADDR'], $allowed_ips, true) &&
			isset($_POST['tr_status']) && $_POST['tr_status'] === 'TRUE' &&
			isset($_POST['tr_amount']) && $_POST['tr_amount'] === $amount &&
            $order->status !== 'P'
		) {
			$model->changeStatus($order, 'P', true, true, JText::_('PLG_DJCATALOG2PAYMENT_TPAY_PAYMENT_COMPLETED'));
		}

        $app->close();
    }

    private function getOrderFreaquency($repeat)
    {
        switch ($repeat) {
            case 'weekly' :
                return 'WEEK';
            case 'monthly' :
                return 'MONTH';
            case 'yearly' :
                return 'YEAR';
        }
    }


    private function log($msg)
    {
        $fp = fopen(__DIR__ . '/lib/logs.txt', 'a');
        fwrite($fp, print_r($msg, true));
        fwrite($fp, "\n");
        fclose($fp);
    }
}

?>

Anon7 - 2022
AnonSec Team