public function PHPValidate($values) { $app = JFactory::getApplication(); if ($app->isAdmin()) { return true; } if (($values === "" || $values === null) && !$this->isRequired()) { return true; } $captchaId = $app->input->getString($this->getId() . "_captcha_namespace", ""); if (!JUDirectoryFrontHelperCaptcha::checkCaptcha($captchaId, $values)) { $message = (string) $this->params->get('invalid_message'); if ($message) { return JText::sprintf($message, $this->getCaption(true)); } else { return JText::sprintf('COM_JUDIRECTORY_FIELD_VALUE_IS_INVALID', $this->getCaption(true)); } } return true; }
public function addComment() { JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); $user = JFactory::getUser(); $model = $this->getModel(); $rootComment = JUDirectoryFrontHelperComment::getRootComment(); $data = $_POST; $listingId = $data['listing_id']; $params = JUDirectoryHelper::getParams(null, $listingId); $parentId = $data['parent_id']; $model->setSessionCommentForm($listingId); if (strlen($data['title']) < 6) { $this->setError(JText::_('COM_JUDIRECTORY_COMMENT_INVALID_TITLE')); $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . '&id=' . $listingId, false)); return false; } if (strlen($data['guest_name']) < 1) { $this->setError(JText::_('COM_JUDIRECTORY_COMMENT_INVALID_NAME')); $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . '&id=' . $listingId, false)); return false; } if (isset($data['guest_email'])) { if (!preg_match('/^[\\w\\.-]+@[\\w\\.-]+\\.[\\w\\.-]{2,6}$/', $data['guest_email'])) { $this->setError(JText::_('COM_JUDIRECTORY_COMMENT_INVALID_EMAIL')); $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . '&id=' . $listingId, false)); return false; } } if (isset($data['website'])) { if (!preg_match('/^(https?:\\/\\/)?([\\w\\.-]+)\\.([\\w\\.-]{2,6})([\\/\\w \\.-]*)*\\/?$/i', $data['website'])) { $this->setError(JText::_('COM_JUDIRECTORY_COMMENT_INVALID_WEBSITE')); $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . '&id=' . $listingId, false)); return false; } } if (isset($data['comment_language'])) { $langArray = JHtml::_('contentlanguage.existing'); $langKey = array_keys($langArray); array_unshift($langKey, '*'); if (!in_array($data['comment_language'], $langKey)) { $this->setError(JText::_('COM_JUDIRECTORY_COMMENT_INVALID_LANGUAGE')); $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . '&id=' . $listingId, false)); return false; } } $minCharacter = $params->get('min_comment_characters', 20); $maxCharacter = $params->get('max_comment_characters', 1000); $comment = $data['comment']; $comment = JUDirectoryFrontHelperComment::parseCommentText($comment, $listingId); $comment = strip_tags($comment); $commentCharacter = strlen($comment); if ($commentCharacter < $minCharacter || $commentCharacter > $maxCharacter) { $this->setError(JText::_('COM_JUDIRECTORY_COMMENT_INVALID_COMMENT')); $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . '&id=' . $listingId, false)); return false; } $showCaptcha = JUDirectoryFrontHelperPermission::showCaptchaWhenComment($listingId); if ($showCaptcha) { $validCaptcha = JUDirectoryFrontHelperCaptcha::checkCaptcha(); if (!$validCaptcha) { if ($parentId == $rootComment->id) { $form = '#judir-comment-form'; } else { $form = '#comment-reply-wrapper-' . $parentId; } $this->setError(JText::_('COM_JUDIRECTORY_INVALID_CAPTCHA')); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . '&id=' . $listingId . $form, false)); return false; } } if ($user->get('guest')) { if (!$model->checkNameOfGuest($listingId)) { $this->setError(JText::_('COM_JUDIRECTORY_YOU_ARE_NOT_AUTHORIZED_TO_COMMENT_ON_THIS_LISTING')); $this->setMessage($model->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . '&id=' . $listingId, false)); return false; } if (!$model->checkEmailOfGuest()) { $this->setMessage($model->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . '&id=' . $listingId, false)); return false; } } if ($parentId == $rootComment->id) { $canComment = JUDirectoryFrontHelperPermission::canComment($listingId, $data['guest_email']); if (!$canComment) { $this->setError(JText::_('COM_JUDIRECTORY_YOU_ARE_NOT_AUTHORIZED_TO_COMMENT_ON_THIS_LISTING')); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . '&id=' . $listingId, false)); return false; } } elseif ($parentId > 0 && $parentId != $rootComment->id) { $canReplyComment = JUDirectoryFrontHelperPermission::canReplyComment($listingId, $parentId); if (!$canReplyComment) { $this->setError(JText::_('COM_JUDIRECTORY_YOU_ARE_NOT_AUTHORIZED_TO_REPLY_THIS_COMMENT')); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . '&id=' . $listingId, false)); return false; } } else { $this->setError(JText::_('COM_JUDIRECTORY_INVALID_DATA')); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . '&id=' . $listingId, false)); return false; } $dataValid = array(); if ($parentId == $rootComment->id) { $canRateListing = JUDirectoryFrontHelperPermission::canRateListing($listingId); if ($canRateListing) { $dataValid = $this->validateCriteria($data, $parentId); if (!$dataValid) { $this->setError(JText::_('COM_JUDIRECTORY_INVALID_RATING_VALUE')); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . '&id=' . $listingId, false)); return false; } } } $requiredPostNames = array('title', 'guest_name', 'guest_email', 'comment', 'parent_id', 'listing_id'); if ($params->get('website_field_in_comment_form', 0) == 2) { array_push($requiredPostNames, 'website'); } if ($parentId == $rootComment->id && $params->get('filter_comment_language', 0)) { array_push($requiredPostNames, 'comment_language'); } foreach ($requiredPostNames as $requiredPostName) { if (trim($data[$requiredPostName]) == '') { $this->setError(JText::_('COM_JUDIRECTORY_INVALID_INPUT_DATA')); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . '&id=' . $listingId, false)); return false; } } $acceptedPostNames = array('title', 'guest_name', 'guest_email', 'language', 'website', 'comment', 'parent_id', 'listing_id', 'subscribe'); if ($params->get('website_field_in_comment_form', 0) == 2 || $params->get('website_field_in_comment_form', 0) == 1) { array_push($acceptedPostNames, 'website'); } if ($params->get('filter_comment_language', 0)) { array_push($acceptedPostNames, 'comment_language'); } foreach ($acceptedPostNames as $acceptedPostName) { if (isset($data[$acceptedPostName])) { $dataValid[$acceptedPostName] = $data[$acceptedPostName]; } } $newCommentId = $model->saveComment($dataValid); if (!$newCommentId) { $this->setError($model->getError()); $this->setMessage($this->getError(), 'error'); $redirectUrl = JRoute::_(JUDirectoryHelperRoute::getListingRoute($listingId), false); $this->setRedirect($redirectUrl); return false; } $session = JFactory::getSession(); $timeNow = JFactory::getDate()->toSql(); $timeNowStamp = strtotime($timeNow); $sessionCommentOnListingTime = 'judir-commented-' . $listingId; $sessionCommentTime = 'judir-commented'; $session->set($sessionCommentOnListingTime, $timeNowStamp); $session->set($sessionCommentTime, $timeNowStamp); $session->clear('judirectory_commentform_' . $listingId); $this->setMessage(JText::_('COM_JUDIRECTORY_ADD_COMMENT_SUCCESSFULLY')); $redirectUrl = JRoute::_(JUDirectoryHelperRoute::getListingRoute($listingId) . '#comment-item-' . $newCommentId, false); $this->setRedirect($redirectUrl); return true; }
?> "> <input name="subscribe" id="comment-reply-subscribe-<?php echo $this->commentObj->id; ?> " class="comment-subscribe" type="checkbox" value="1"/> <?php echo JText::_('COM_JUDIRECTORY_COMMENT_SUBSCRIBE'); ?> </label> </div> <?php } if (JUDirectoryFrontHelperPermission::showCaptchaWhenComment($this->item->id)) { echo JUDirectoryFrontHelperCaptcha::getCaptcha(true); } ?> </div> <div class="comment-form-submit clearfix"> <button type="button" class="btn btn-primary" onclick="Joomla.submitbutton('listing.addComment', 'judir-comment-reply-form-<?php echo $this->commentObj->id; ?> ');"><?php echo JText::_('COM_JUDIRECTORY_SUBMIT'); ?> </button> <input type="reset" name="reply-reset" class="btn" value="<?php
<div class="col-sm-10"> <input type="text" class="required email" name="jform[email]" value="" id="inputEmail" size="32"/> </div> </div> <div class="form-group"> <label for="security_code" class="control-label col-sm-2"> <?php echo JText::_('COM_JUDIRECTORY_CAPTCHA'); ?> <span style="color: red">*</span> </label> <div class="col-sm-10"> <?php echo JUDirectoryFrontHelperCaptcha::getCaptcha(false, null, false); ?> </div> </div> <div class="form-group"> <label class="control-label col-sm-2"></label> <div class="col-sm-10"> <button type="button" class="btn btn-default btn-primary" onclick="Joomla.submitbutton('subscribe.save')"> <?php echo JText::_('COM_JUDIRECTORY_SUBMIT'); ?> </button> <button type="button" class="btn btn-default" onclick="Joomla.submitbutton('subscribe.cancel')"> <?php
public static function checkCaptcha($namespace = null, $captcha = '') { if (!$namespace) { $namespace = JFactory::getApplication()->input->getString('captcha_namespace', ''); } if (!$captcha) { $captcha = JFactory::getApplication()->input->getString('security_code', ''); } if ($captcha && $namespace) { $secureImage = JUDirectoryFrontHelperCaptcha::initCaptcha($namespace); if ($secureImage->check($captcha, true) == true) { return true; } } return false; }
JLoader::register('JUDIRView', JPATH_SITE . '/components/com_judirectory/helpers/judirview.php'); JLoader::register('JUDIRPagination', JPATH_SITE . '/components/com_judirectory/helpers/judirpagination.php'); JLoader::register('JUDIRModelList', JPATH_SITE . '/components/com_judirectory/helpers/judirmodellist.php'); JLoader::register('JUDirectorySearchHelper', JPATH_SITE . '/components/com_judirectory/helpers/search.php'); spl_autoload_register(array('JUDirectoryHelper', 'autoLoadFieldClass')); JUDirectoryFrontHelperLanguage::loadLanguageForTopLevelCat(); JUDirectoryFrontHelperLanguage::loadLanguageFile("com_judirectory.custom"); if (JUDirectoryHelper::isJoomla3x()) { JHtml::_('script', 'system/core.js', false, true); } $app = JFactory::getApplication(); $task = $app->input->get('task'); switch ($task) { case 'captcha': $namespace = $app->input->getString('captcha_namespace', ''); JUDirectoryFrontHelperCaptcha::captchaSecurityImages($namespace); exit; break; case 'rawdata': $field_id = $app->input->getInt('field_id', 0); $listing_id = $app->input->getInt('listing_id', 0); $fieldObj = JUDirectoryFrontHelperField::getField($field_id, $listing_id); JUDirectoryHelper::obCleanData(); $fieldObj->getRawData(); exit; break; case 'cron': JUDirectoryFrontHelperMail::sendMailq(); exit; break; default: