Exemplo n.º 1
0
 /**
  * Internal element validation
  *
  * @param   array $data          form data
  * @param   int   $repeatCounter repeat group counter
  *
  * @return bool
  */
 public function validate($data, $repeatCounter = 0)
 {
     $params = $this->getParams();
     $input = $this->app->input;
     if (!$this->canUse()) {
         return true;
     }
     if ($params->get('captcha-method') == 'recaptcha') {
         if (!function_exists('_recaptcha_qsencode')) {
             require_once JPATH_SITE . '/plugins/fabrik_element/captcha/libs/recaptcha-php-1.11/recaptchalib.php';
         }
         $privateKey = $params->get('recaptcha_privatekey');
         if ($input->get('recaptcha_response_field')) {
             $challenge = $input->get('recaptcha_challenge_field');
             $response = $input->get('recaptcha_response_field');
             $resp = recaptcha_check_answer($privateKey, FabrikString::filteredIp(), $challenge, $response);
             return $resp->is_valid ? true : false;
         }
         return false;
     } elseif ($params->get('captcha-method') == 'nocaptcha') {
         if ($input->get('g-recaptcha-response')) {
             require_once JPATH_SITE . '/plugins/fabrik_element/captcha/libs/ReCaptcha/ReCaptcha.php';
             require_once JPATH_SITE . '/plugins/fabrik_element/captcha/libs/ReCaptcha/RequestMethod.php';
             require_once JPATH_SITE . '/plugins/fabrik_element/captcha/libs/ReCaptcha/RequestMethod/Post.php';
             require_once JPATH_SITE . '/plugins/fabrik_element/captcha/libs/ReCaptcha/RequestParameters.php';
             require_once JPATH_SITE . '/plugins/fabrik_element/captcha/libs/ReCaptcha/Response.php';
             $privateKey = $params->get('recaptcha_privatekey');
             $noCaptcha = new \ReCaptcha\ReCaptcha($privateKey);
             $response = $input->get('g-recaptcha-response');
             $server = $input->server->get('REMOTE_ADDR');
             $resp = $noCaptcha->verify($response, $server);
             if ($resp->isSuccess()) {
                 return true;
             } else {
                 if (FabrikHelperHTML::isDebug()) {
                     $msg = "noCaptcha error: ";
                     foreach ($resp->getErrorCodes() as $code) {
                         $msg .= '<tt>' . $code . '</tt> ';
                     }
                     $this->app->enqueueMessage($msg);
                 }
                 return false;
             }
         }
         if (FabrikHelperHTML::isDebug()) {
             $this->app->enqueueMessage("No g-recaptcha-response!");
         }
         return false;
     } elseif ($params->get('captcha-method') == 'playthru') {
         if (!defined('AYAH_PUBLISHER_KEY')) {
             define('AYAH_PUBLISHER_KEY', $params->get('playthru_publisher_key', ''));
             define('AYAH_SCORING_KEY', $params->get('playthru_scoring_key', ''));
         }
         require_once JPATH_SITE . '/plugins/fabrik_element/captcha/libs/ayah_php_bundle_1.1.7/ayah.php';
         $ayah = new AYAH();
         return $ayah->scoreResult();
     } else {
         $this->getParams();
         if ($this->session->get('com_' . $this->package . '.element.captcha.security_code', null) != $data) {
             return false;
         }
         return true;
     }
 }
Exemplo n.º 2
0
 /**
  * Make a standard log message
  *
  * @param   string $result_compare Not sure?!
  *
  * @return  string  json encoded objects
  */
 protected function makeStandardMessage($result_compare)
 {
     $params = $this->getParams();
     $input = $this->app->input;
     $msg = new stdClass();
     if ($params->get('logs_record_ip') == 1) {
         $msg->ip = FabrikString::filteredIp();
     }
     if ($params->get('logs_record_useragent') == 1) {
         $msg->userAgent = $input->server->getString('HTTP_USER_AGENT');
     }
     if ($params->get('compare_data') == 1) {
         $result_compare = preg_replace('/<br\\/>/', '- ', $result_compare);
         $msg->comparison = preg_replace('/\\n/', '- ', $result_compare);
     }
     return json_encode($msg);
 }
Exemplo n.º 3
0
 /**
  * Get the cookie name
  *
  * @param   int     $listId  List id
  * @param   string  $rowId  Row id
  *
  * @return  string
  */
 private function getCookieName($listId, $rowId)
 {
     $cookieName = 'thumb-table_' . $listId . '_row_' . $rowId . '_ip_' . FabrikString::filteredIp();
     jimport('joomla.utilities.utility');
     $version = new JVersion();
     if (version_compare($version->RELEASE, '3.1', '>')) {
         return JApplicationHelper::getHash($cookieName);
     } else {
         return JApplication::getHash($cookieName);
     }
 }
Exemplo n.º 4
0
 /**
  * This really does get just the default value (as defined in the element's settings)
  *
  * @param   array  $data  form data
  *
  * @return mixed
  */
 public function getDefaultValue($data = array())
 {
     if (!isset($this->default)) {
         $this->default = FabrikString::filteredIp();
     }
     return $this->default;
 }
Exemplo n.º 5
0
 /**
  * Get cookie name
  *
  * @param   int     $listId  List id
  * @param   string  $rowId  Row id
  *
  * @return string  Hashed cookie name.
  */
 private function getCookieName($listId, $rowId)
 {
     $cookieName = "rating-table_{$listId}_row_{$rowId}" . FabrikString::filteredIp();
     jimport('joomla.utilities.utility');
     return JApplication::getHash($cookieName);
 }
Exemplo n.º 6
0
 /**
  * Add a comment called from ajax request
  *
  * @return  void
  */
 public function onAddComment()
 {
     $input = $this->app->input;
     $row = FabTable::getInstance('comment', 'FabrikTable');
     $filter = JFilterInput::getInstance();
     $request = $filter->clean($_REQUEST, 'array');
     $row->bind($request);
     $row->ipaddress = FabrikString::filteredIp();
     $row->user_id = $this->user->get('id');
     $row->approved = 1;
     // @TODO this isn't set?
     $row->url = $input->server->get('HTTP_REFERER', '', 'string');
     $rowId = $input->get('rowid', '', 'string');
     $row->formid = $input->getInt('formid');
     $row->row_id = $rowId;
     if ($this->user->get('id') != 0) {
         $row->name = $this->user->get('name');
         $row->email = $this->user->get('email');
     }
     // Load up the correct params for the plugin -
     // First load all form params
     $formModel = $this->setFormModel();
     $params = $formModel->getParams();
     $this->renderOrder = (int) $input->get('renderOrder', 0);
     // Then map that data (for correct render order) onto this plugins params
     $params = $this->setParams($params, $this->renderOrder);
     $row->store();
     // $$$ rob 16/10/2012 db queries run when element/plugin selected in admin, so just return false if error now
     $obj = new stdClass();
     // Do this to get the depth of the comment
     $comments = $this->getComments($row->formid, $row->row_id);
     $row = $comments[$row->id];
     $obj->content = $this->writeComment($params, $row);
     $obj->depth = (int) $row->depth;
     $obj->id = $row->id;
     $notificationPlugin = $this->useNotificationPlugin();
     $this->fixTable();
     if ($notificationPlugin) {
         $this->addNotificationEvent($row);
     }
     // Do we notify everyone?
     if ($notificationPlugin) {
         $this->saveNotificationToPlugin($row, $comments);
     } else {
         $this->sentNotifications($row, $comments);
     }
     echo json_encode($obj);
 }