I need to block access to all URLs that doesn't contain &uuid=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
the x
is random and can contain number and text.
The final code needs to have both verifications in it: if ($context->data->ticket->ohanah_event_id)
and the URL check.
The Code used at the Moment is:
<?php
/**
* @package Ohanah
* @copyright Copyright (C) 2012 - 2016 Beyounic SA. All rights reserved.
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
* @link http://www.beyounic.com
*/
class ComOhanahViewTicketHtml extends ComOhanahViewHtml
{
protected function _fetchData(KViewContext $context)
{
parent::_fetchData($context);
if ($context->data->ticket->ohanah_event_id) {
$doc = JFactory::getDocument();
$translator = $this->getObject('translator');
$doc->setTitle($translator->translate('COM_OHANAH_TICKET') . ' - ' . $context->data->ticket->event->title);
}
}
}
This would be something like this.. if you give me more precisions of what the uuid format will be, i can update with a better regex. Some things like if the the example shows the accurate number of x
separated by -
, the regex would be '/^[A-Za-z0-9]{8}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{12}$/'
. (Note that theses regexes does not support accented characters)
class ComOhanahViewTicketHtml extends ComOhanahViewHtml
{
protected function _fetchData(KViewContext $context)
{
parent::_fetchData($context);
if(!isset($_GET['uuid']) || !preg_match('/^[A-Za-z0-9-]*$/', $_GET['uuid'])){
exit('URL NOT ALLOWED!');
}else{
if ($context->data->ticket->ohanah_event_id) {
$doc = JFactory::getDocument();
$translator = $this->getObject('translator');
$doc->setTitle($translator->translate('COM_OHANAH_TICKET') . ' - ' . $context->data->ticket->event->title);
}
}
}
}
Note that if headers are not sent yet, you can add an accurate forbidden error with header('HTTP/1.0 403 Forbidden');
(simple version, you can find better ones that accept HTTPS and all)