| Server IP : 54.36.91.62 / Your IP : 216.73.217.111 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/components/com_djcatalog2/controllers/ |
Upload File : |
<?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
*/
defined('_JEXEC') or die( 'Restricted access' );
use Joomla\CMS\Factory;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\MVC\Controller\AdminController;
jimport('joomla.application.component.controlleradmin');
class Djcatalog2ControllerOrders extends AdminController
{
public function downloadExport() {
$app = Factory::getApplication();
$jinput = $app->input;
$user = Factory::getUser();
if ($user->guest) {
throw new Exception(Text::_('JERROR_ALERTNOAUTHOR'), 403);
}
$file = $jinput->get('file', null, 'base64');
if(!strlen($file)) {
throw new Exception(Text::_('COM_DJCATALOG2_FILE_NOT_FOUND'), 403);
}
$app = Factory::getApplication();
$user = Factory::getUser();
$file_path = Djcatalog2ExportHelper::getExportPath('order') . '/' . base64_decode(($file));
if (strpos($file_path, 'U' . $user->id .'.csv') === false) {
throw new Exception(Text::_('JERROR_ALERTNOAUTHOR'), 403);
}
if (empty($file) || !File::exists($file_path) || strpos($file_path, 'media') === false || strpos($file_path, 'djcatalog2') === false) {
$this->setRedirect( 'index.php?option=com_djcatalog2', Text::sprintf('COM_DJCATALOG2_ERROR_FILE_MISSING', base64_decode($file)), 'error' );
return false;
}
if (!DJCatalog2FileHelper::getFileByPath($file_path, null, 'text/csv')){
//JError::raiseError(404);
throw new Exception('', 404);
return false;
}
$app->close();
return true;
}
public function export() {
$this->checkToken();
$user = Factory::getUser();
if ($user->guest) {
throw new Exception(Text::_('JERROR_ALERTNOAUTHOR'), 403);
}
$params = DJCatalog2Helper::getParams();
if(!$params->get('export_orders_frontend')) {
throw new Exception(Text::_('COM_DJCATALOG2_FRONTEND_ORDER_EXPORT_DISABLED'), 403);
}
$app = Factory::getApplication();
$jinput = $app->input;
$cid = $jinput->get('cid', array(), 'array');
$file = Djcatalog2ExportHelper::exportOrders($cid);
if($file['success']) {
$file_link = '<a href="' . Route::_('index.php?option=com_djcatalog2&task=orders.downloadExport&file=' . base64_encode($file['filename'])) . '">' . $file['filename'] . '</a></br>';
$this->setRedirect(Route::_('index.php?option=com_djcatalog2&view=orders'), Text::_('COM_DJCATALOG2_EXPORT_SUCCESFULL') . ' ' . $file_link);
}
}
public function accesstoken() {
$app = Factory::getApplication();
$id = $app->input->getInt('id');
$token = $app->input->getCmd('token');
$return = $app->input->getBase64('return');
if (!$return) {
$return = 'index.php';
} else {
$return = base64_decode($return);
}
$response = [
'redirect' => false,
'body' => '',
'message' => '',
'error' => false
];
$response['redirect'] = Route::_($return, false, Uri::getInstance()->isSsl() ? 1 : -1);
$orders = Djcatalog2HelperUser::getOrdersByToken($token);
$auth = false;
if (!empty($orders['items'])) {
foreach($orders['items'] as $purchasedItem) {
$app->setUserState('com_djcatalog2.accesstoken.' . $purchasedItem->item_id, true);
if ($purchasedItem->item_id != $id) continue;
$auth = true;
}
}
if (!$auth) {
$response['error'] = Text::_('COM_DJCATALOG2_AUTH_ERROR_TOKEN_INVALID');
}
if ($app->input->getInt('is_ajax')) {
echo json_encode($response);
$app->close();
}
if ($response['message']) {
$app->enqueueMessage($response['message']);
}
if ($response['error']) {
$app->enqueueMessage($response['error'], 'error');
}
$this->setRedirect($response['redirect']);
return true;
}
}