/** * Method to test if the Captcha is correct. * * @param SimpleXMLElement $element The SimpleXMLElement object representing the `<field>` tag for the form field object. * @param mixed $value The form field value to validate. * @param string $group The field name group control value. This acts as as an array container for the field. * For example if the field has name="foo" and the group value is set to "bar" then the * full field name would end up being "bar[foo]". * @param Registry $input An optional Registry object with the entire data set to validate against the entire form. * @param JForm $form The form object for which the field is being tested. * * @return boolean True if the value is valid, false otherwise. * * @since 2.5 */ public function test(SimpleXMLElement $element, $value, $group = null, Registry $input = null, JForm $form = null) { $app = JFactory::getApplication(); $plugin = $app->get('captcha'); if ($app->isSite()) { $plugin = $app->getParams()->get('captcha', $plugin); } $namespace = $element['namespace'] ?: $form->getName(); // Use 0 for none if ($plugin === 0 || $plugin === '0') { return true; } else { $captcha = JCaptcha::getInstance((string) $plugin, array('namespace' => (string) $namespace)); } // Test the value. if (!$captcha->checkAnswer($value)) { $error = $captcha->getError(); if ($error instanceof Exception) { return $error; } else { return new JException($error); } } return true; }
/** * Render comments and respond form html. * * @param AppView $view The view the comments are rendered on * @param Item $item The item whos comments are rendered * * @return string The html output * * @since 2.0 */ public function renderComments($view, $item) { if ($item->getApplication()->isCommentsEnabled()) { // get application params $params = $this->app->parameter->create($item->getApplication()->getParams()->get('global.comments.')); if ($params->get('twitter_enable') && !function_exists('curl_init')) { $this->app->error->raiseWarning(500, JText::_('To use Twitter, CURL needs to be enabled in your php settings.')); $params->set('twitter_enable', false); } // get active author $active_author = $this->activeAuthor(); // get comment content from session $content = $this->app->system->session->get('com_zoo.comment.content'); $params->set('content', $content); // get comments and build tree $approved = $item->canManageComments() ? Comment::STATE_UNAPPROVED : Comment::STATE_APPROVED; $comments = $item->getCommentTree($approved); // build captcha $captcha = false; if ($plugin = $params->get('captcha', false) and (!$params->get('captcha_guest_only', 0) or !$this->app->user->get()->id)) { $captcha = JCaptcha::getInstance($plugin); } if ($item->isCommentsEnabled() || count($comments) - 1) { // create comments html return $view->partial('comments', compact('item', 'active_author', 'comments', 'params', 'captcha')); } } return null; }
protected function displayCaptcha() { $plugin = JFactory::getConfig()->get('captcha'); if ($plugin == '0') { $plugin = 'recaptcha'; } $captcha = JCaptcha::getInstance($plugin); if ($captcha instanceof JCaptcha) { return $captcha->display('captcha', 'jea-captcha'); } return ''; }
/** * Method to get the field input. * * @return string The field input. * * @since 2.5 */ protected function getInput() { $class = $this->element['class'] ? (string) $this->element['class'] : ''; $plugin = $this->element['plugin'] ? (string) $this->element['plugin'] : JFactory::getApplication()->getParams()->get('captcha', JFactory::getConfig()->get('captcha')); $namespace = $this->element['namespace'] ? (string) $this->element['namespace'] : $this->form->getName(); // Use 0 for none if ($plugin === 0 || $plugin === '0' || $plugin === '' || $plugin === null) { return ''; } else { if (($captcha = JCaptcha::getInstance($plugin, array('namespace' => $namespace))) == null) { return ''; } } return $captcha->display($this->name, $this->id, $class); }
static function validateCaptcha() { $params = self::getParams(); if ($params->get('captcha_system', false)) { $captcha = JFactory::getApplication()->getParams()->get('captcha', JFactory::getConfig()->get('captcha')); if ($captcha === 0 || $captcha === '0' || $captcha === '' || $captcha === null) { return ''; } if (($captcha = JCaptcha::getInstance($captcha, array('namespace' => $name))) == null) { return ''; } return $captcha->checkAnswer(''); } else { return self::_validateMathGuard(); } }
/** * */ public function __construct($params) { $this->params = $params; $this->values = JFactory::getApplication()->input->post->get('bfcustform', array(), 'array'); $captchaName = $this->params->get('captcha', JFactory::getConfig()->get('captcha')); if ($captchaName != '-') { $this->captcha = JCaptcha::getInstance($captchaName); if (!empty($this->captcha) && !empty($this->values)) { if (!$this->captcha->checkAnswer(null)) { if (count($errors = $this->captcha->getErrors('Errors'))) { JError::raiseWarning(500, implode("\n", $errors)); $this->captchaValid = false; } } } } if (!empty($this->values) && $this->captchaValid) { $this->readytoSend = true; } }
/** * Method to test if the Captcha is correct. * * @param SimpleXMLElement &$element The SimpleXMLElement object representing the <field /> tag for the form field object. * @param mixed $value The form field value to validate. * @param string $group The field name group control value. This acts as as an array container for the field. * For example if the field has name="foo" and the group value is set to "bar" then the * full field name would end up being "bar[foo]". * @param JRegistry &$input An optional JRegistry object with the entire data set to validate against the entire form. * @param JForm &$form The form object for which the field is being tested. * * @return boolean True if the value is valid, false otherwise. * * @since 2.5 */ public function test(&$element, $value, $group = null, &$input = null, &$form = null) { $plugin = $element['plugin'] ? (string) $element['plugin'] : JFactory::getApplication()->getParams()->get('captcha', JFactory::getConfig()->get('captcha', 0)); $namespace = $element['namespace'] ? (string) $element['namespace'] : $form->getName(); // Use 0 for none if ($plugin === 0 || $plugin === '0') { return true; } else { $captcha = JCaptcha::getInstance($plugin, array('namespace' => $namespace)); } // Test the value. if (!$captcha->checkAnswer($value)) { $error = $captcha->getError(); if ($error instanceof Exception) { return $error; } else { return new JException($error); } } return true; }
} else { $effect = 'btl-modal'; } //setting for registration $usersConfig = JComponentHelper::getParams('com_users'); $enabledRegistration = false; $viewName = JRequest::getVar('view', 'registry'); $enabledRecaptcha = 'none'; if ($usersConfig->get('allowUserRegistration') && $params->get("enabled_registration", 1) && ($viewName != "registration" || $integrated_com != '')) { $enabledRegistration = true; $enabledRecaptcha = $params->get('use_captcha', 1); if ($enabledRecaptcha == 1) { //create instance captcha, get recaptcha $captcha = JFactory::getConfig()->get('captcha'); if ($captcha) { $reCaptcha = JCaptcha::getInstance($captcha); $reCaptcha = $reCaptcha->display('bt-login-recaptcha', 'bt-login-recaptcha', 'bt-login-recaptcha'); } else { $reCaptcha = ''; $enabledRecaptcha = 0; } } else { if ($enabledRecaptcha == 2) { $reCaptcha = modbt_loginHelper::getBuiltinCaptcha(); } } } $language = JFactory::getLanguage(); require JModuleHelper::getLayoutPath('mod_bt_login'); ?>
public static function ajax() { $mainframe =& JFactory::getApplication('site'); //JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $bttask = JRequest::getVar('bttask'); /** * check task is login to do */ if ($bttask == 'login') { if ($return = JRequest::getVar('return', '', 'method', 'base64')) { $return = base64_decode($return); if (!JURI::isInternal($return)) { $return = ''; } } $options = array(); $options['remember'] = JRequest::getBool('remember', false); $options['return'] = $return; $credentials = array(); $credentials['username'] = JRequest::getVar('username', '', 'method', 'username'); $credentials['password'] = JRequest::getString('passwd', '', 'post', JREQUEST_ALLOWRAW); //preform the login action $error = $mainframe->login($credentials, $options); self::ajaxResponse($error); } elseif ($bttask == 'register') { /** * check task is registration to do */ // If registration is disabled - Redirect to login page. if (JComponentHelper::getParams('com_users')->get('allowUserRegistration') == 0) { // set message in here : Registration is disable self::ajaxResponse("Registration is not allowed!"); } //check captcha $enabledRecaptcha = JRequest::getVar('recaptcha'); if ($enabledRecaptcha == 'yes') { if (JRequest::getVar('recaptcha_response_field')) { $captcha = JCaptcha::getInstance('recaptcha'); //$captcha->initialise('6Lf7Js8SAAAAAJBSx3JdwDKN0F1kVTF47Uz_DEli '); $checkCaptcha = $captcha->checkAnswer(JRequest::getVar('recaptcha_response_field')); if ($checkCaptcha == false) { self::ajaxResponse('$error$' . JText::_('PLG_RECAPTCHA_ERROR_INCORRECT_CAPTCHA_SOL')); } } elseif (JRequest::getString('btl_captcha')) { $session = JFactory::getSession(); echo $session->get('btl_captcha'); if (JRequest::getString('btl_captcha') != $session->get('btl_captcha')) { self::ajaxResponse('$error$' . JText::_('INCORRECT_CAPTCHA')); } } else { self::ajaxResponse('$error$' . JText::_('INCORRECT_CAPTCHA')); } } // Get the user data. // reset params form name in getVar function (not yet) $requestData['name'] = JRequest::getVar('name'); $requestData['username'] = JRequest::getVar('username'); $requestData['password1'] = JRequest::getVar('passwd1'); $requestData['password2'] = JRequest::getVar('passwd2'); $requestData['email1'] = JRequest::getVar('email1'); $requestData['email2'] = JRequest::getVar('email2'); // Save the data in the session. // may be use //$app->setUserState('com_users.registration.data', $requestData); // Attempt to save the data. $return = self::register($requestData); if ($return === 'adminactivate') { self::ajaxResponse(JText::_('COM_USERS_REGISTRATION_COMPLETE_VERIFY')); } elseif ($return === 'useractivate') { self::ajaxResponse(JText::_('COM_USERS_REGISTRATION_COMPLETE_ACTIVATE')); } else { self::ajaxResponse(JText::_('COM_USERS_REGISTRATION_SAVE_SUCCESS')); } } else { self::ajaxResponse(self::createCaptcha()); } }
public function save() { // check for request forgeries $this->app->session->checkToken() or jexit('Invalid Token'); // init vars $post = $this->app->request->get('post:', 'array'); $msg = null; try { $this->_init(); // set name on new item if (!($edit = (bool) $this->item->id)) { $this->item->name = JText::_('Submitted Item'); } // If it's a new item and the user has reached the max number of submissions, trigger error if (!$this->item->id && !$this->_checkMaxSubmissions()) { throw new AppControllerException('You have reached your maximum number of submissions'); } // get element data from post if (isset($post['elements'])) { // filter element data if (!$this->submission->isInTrustedMode() && !$this->app->user->isJoomlaAdmin($this->user)) { $this->app->request->setVar('elements', $this->app->submission->filterData($post['elements'])); $post = $this->app->request->get('post:', 'array'); } // merge elements into post $post = array_merge($post, $post['elements']); } // merge userfiles element data with post data foreach ($_FILES as $key => $userfile) { if (strpos($key, 'elements_') === 0) { $post[str_replace('elements_', '', $key)]['userfile'] = $userfile; } } $item_name = $this->item->name; $error = $this->_bind($post); // Check captcha if ($plugin = $this->submission->getParams()->get('captcha', false) and (!$this->submission->getParams()->get('captcha_guest_only', 0) or !$this->app->user->get()->id)) { $captcha = JCaptcha::getInstance($plugin); if (!$captcha->checkAnswer(@$post['captcha'])) { $error = $captcha->getError(); if (!$error instanceof Exception) { $error = new JException($error); } // raise warning on exception $this->app->error->raiseWarning(0, JText::_('ZOO_CHECK_CAPTCHA') . ' - ' . JText::_($error)); } } // save item if it is valid if (!$error) { // set alias if (!$edit || $item_name != $this->item->name) { $this->item->alias = $this->app->alias->item->getUniqueAlias($this->item->id, $this->app->string->sluggify($this->item->name)); } // unpublish item in none trusted state if (!$this->submission->isInTrustedMode() && !in_array('_itemstate', array_keys($this->elements_config))) { $this->item->state = 0; } // set modified $this->item->modified = $this->app->date->create()->toSQL(); $this->item->modified_by = $this->user->get('id'); // enforce time limit on submissions if (!$edit && !$this->submission->isInTrustedMode()) { $timestamp = time(); if ($timestamp < $this->app->system->session->get('ZOO_LAST_SUBMISSION_TIMESTAMP') + SubmissionController::TIME_BETWEEN_PUBLIC_SUBMISSIONS) { $this->app->system->application->setUserState($this->session_form_key, serialize($post)); throw new SubmissionControllerException('You are submitting too fast, please try again in a few moments.'); } $this->app->system->session->set('ZOO_LAST_SUBMISSION_TIMESTAMP', $timestamp); } // deprecated as of version 2.5.7 call to doUpload, use before save event instead foreach ($this->elements_config as $element) { if (($element = $this->item->getElement($element['element'])) && $element instanceof iSubmissionUpload) { $element->doUpload(); } } // Add primary category if no primary category is set (i.e: no itemcategory element present) $primary_category = $this->item->getPrimaryCategory(); if (!$edit && empty($primary_category) && ($category = $this->submission->getForm($this->type->id)->get('category'))) { $this->item->getParams()->set('config.primary_category', $category); } // trigger before save event $this->app->event->dispatcher->notify($this->app->event->create($this->submission, 'submission:beforesave', array('item' => $this->item, 'new' => !$edit))); // save item $this->app->table->item->save($this->item, false); // save to default category if (!$edit && ($category = $this->submission->getForm($this->type->id)->get('category'))) { $this->app->category->saveCategoryItemRelations($this->item, array($category)); } // set redirect message $msg = JText::_($edit ? 'Item saved' : ($this->submission->isInTrustedMode() ? 'Thanks for your submission.' : 'Thanks for your submission. It will be reviewed before being posted on the site.')); // trigger saved event $this->app->event->dispatcher->notify($this->app->event->create($this->submission, 'submission:saved', array('item' => $this->item, 'new' => !$edit))); } else { // add post data to session if form is not valid $this->app->system->application->setUserState($this->session_form_key, serialize($post)); } } catch (SubmissionControllerException $e) { $error = true; // raise warning on exception $this->app->error->raiseWarning(0, (string) JText::_($e)); } catch (AppException $e) { $error = true; // raise warning on exception $this->app->error->raiseWarning(0, JText::_('There was an error saving your submission, please try again later.')); // add exception details, for super administrators only if ($this->user->superadmin) { $this->app->error->raiseWarning(0, (string) $e); } } // If an error is found, redirect to the edit form itself $link = $error ? $this->app->route->submission($this->submission, $this->type->id, null, $this->item_id, $this->redirectTo) : $this->_getRedirectLink(); $this->setRedirect(JRoute::_($link, false), $msg); }
public static function drawHTMLPage($id) { $item = 1; $form = baformsHelper::getForm($id); $columns = baformsHelper::getColumn($id); $elements = baformsHelper::getElement($id); $popup = baformsHelper::getPopup($id); $submissionsOptions = baformsHelper::getSubmisionOptions($id); $embed = self::getEmbed($id); $html = "<div class='com-baforms'>"; $title = $form[0]->title; $titleSettings = $form[0]->title_settings; $formSettings = $form[0]->form_settings; $formSettings = explode('/', $formSettings); $uri = JURI::getInstance(); $url = $uri->toString(array('scheme', 'host', 'port')) . JURI::root(true); $url .= '/index.php?option=com_baforms&view=form&task=form.save&form_id='; $url .= $id; $language = JFactory::getLanguage(); $language->load('com_baforms', JPATH_ADMINISTRATOR); $formStyle = explode(';', $formSettings[9]); if (empty($submissionsOptions['message_bg_rgba'])) { $submissionsOptions['message_bg_rgba'] = '#ffffff'; } if (empty($submissionsOptions['message_color_rgba'])) { $submissionsOptions['message_color_rgba'] = '#333333'; } if (empty($submissionsOptions['dialog_color_rgba'])) { $submissionsOptions['dialog_color_rgba'] = 'rgba(0, 0, 0, 0.15)'; } $html .= '<div class="modal-scrollable"><div class="ba-modal fade hide message-modal"'; $html .= ' style="color:' . $submissionsOptions['message_color_rgba']; $html .= '; background-color: ' . $submissionsOptions['message_bg_rgba']; $html .= ';"><div class="ba-modal-body"><span class="message"></span><input type="hidden" value="'; $html .= $submissionsOptions['dialog_color_rgba'] . '" class="dialog-color"></div></div></div>'; if ($popup['display_popup'] == 1) { $html .= '<div class="btn-' . $popup['button_position'] . '">'; $html .= "<input type='button' value='" . $popup['button_lable']; $html .= "' style='background-color: " . $popup['button_bg']; $html .= "; font-weight:" . $popup['button_weight']; $html .= "; border-radius:" . $popup['button_border'] . "px"; $html .= "; font-size:" . $popup['button_font_size'] . "px"; $html .= "; color: " . $popup['button_color'] . "'"; $html .= " data-popup='popup-form-" . $id . "' class='popup-btn'>"; $html .= '</div><div class="modal-scrollable"><div class="ba-modal'; $html .= ' fade hide popup-form" id="popup-form-' . $id . '" style="display: none; '; $html .= $formStyle[0] . '">'; $html .= '<div class="ba-modal-body">'; } $html .= '<form action="' . $url . '"'; $html .= ' method="post" class="form-validate" enctype="multipart/form-data">'; $html .= '<div style="'; if ($popup['display_popup'] == 0) { $html .= $formStyle[0] . '; '; } $html .= $formStyle[1] . ';' . $formStyle[2] . ';' . $formStyle[3]; $html .= '" class="ba-form ' . $formSettings[0] . '">'; if ($submissionsOptions['display_title'] == 1) { $html .= '<div class="row-fluid ba-row" style="' . $titleSettings . '"><div class="span12">'; $html .= $title . '</div></div>'; } $row = ''; $k = 0; if (empty($columns)) { foreach ($elements as $element) { $element = explode('_-_', $element->settings); if ($element[0] == 'button') { $button = $element[1]; $buttonStyle = $element[2]; $buttonAligh = $element[3]; } } } $n = 1; $html .= '<div class="page-0">'; foreach ($columns as $column) { $column = explode(',', $column->settings); if (trim($column[1]) == 'spank') { $prev = $column[3]; $prev = explode(';', $prev); $next = $column[5]; $next = explode(';', $next); if ($n != 1) { $html .= '<div class="ba-prev"><input type="button" value="'; $html .= $prev[0] . '" style="border-radius:' . $prev[7]; $html .= 'px; background-color: #' . $prev[3] . '; font-size:'; $html .= $prev[5] . 'px; font-weight:' . $prev[6] . '; width:'; $html .= $prev[1] . 'px; height:' . $prev[2] . 'px; color: #' . $prev[4]; $html .= '" class="btn-prev"></div>'; } if ($n == 1) { $last = $prev; } $html .= '<div class="ba-next"><input type="button" value="'; $html .= $next[0] . '" style="border-radius:' . $next[7]; $html .= 'px; background-color: #' . $next[3] . '; font-size:'; $html .= $next[5] . 'px; font-weight:' . $next[6] . '; width:'; $html .= $next[1] . 'px; height:' . $next[2] . 'px; color: #' . $next[4]; $html .= '" class="btn-next"></div></div>'; $html .= '<div class="page-' . $n . '" style="display:none">'; $n++; } if (trim($column[1]) == 'span12') { $html .= '<div class="row-fluid ba-row">'; } if (trim($column[1]) == 'span6') { if ($row == 1) { $row = 2; } if ($row == '') { $html .= '<div class="row-fluid ba-row">'; $row = 1; } } if (trim($column[1]) == 'span4') { if ($row == 2) { $row = 3; } if ($row == 1) { $row = 2; } if ($row == '') { $html .= '<div class="row-fluid ba-row">'; $row = 1; } } if (trim($column[1]) == 'span3') { if ($row == 3) { $row = 4; } if ($row == 2) { $row = 3; } if ($row == 1) { $row = 2; } if ($row == '') { $html .= '<div class="row-fluid ba-row">'; $row = 1; } } if (trim($column[1]) != 'spank') { $html .= '<div class="' . $column[1] . '">'; foreach ($elements as $element) { $element = explode('_-_', $element->settings); if ($element[0] == 'button') { $button = $element[1]; $buttonStyle = $element[2]; $buttonAligh = $element[3]; } if ($element[0] == $column[0]) { if ($element[2] == 'textInput') { $options = explode(';', $element[3]); $html .= '<div class="ba-textInput tool">'; if ($options[0] != '') { $html .= '<label style="font-size:' . $formSettings[1] . '; color:'; $html .= $formSettings[2] . '; font-weight: '; $html .= $formSettings[10] . '"><span title="'; $html .= htmlspecialchars($options[1]) . '">' . htmlspecialchars($options[0]); if (isset($options[3])) { if ($options[3] == 1) { $html .= ' *'; } } $html .= '</span></label>'; } if (!isset($options[4]) || empty($options[4])) { $options[4] = 'regular'; } $html .= '<input type="text" data-type="' . $options[4]; $html .= '" style="height:' . $formSettings[3] . '; '; $html .= 'font-size:' . $formSettings[4] . ';color:' . $formSettings[5]; $html .= '; background-color:' . $formSettings[6] . '; '; $html .= $formSettings[7] . '; border-radius:' . $formSettings[8] . '"'; $html .= " placeholder='" . htmlspecialchars($options[2], ENT_QUOTES) . "'"; $html .= " name='"; $html .= $item; $item++; $html .= "'"; if (isset($options[3])) { if ($options[3] == 1) { $html .= ' required'; } } $html .= '><br></div>'; } if ($element[2] == 'email') { $options = explode(';', $element[3]); $html .= '<div class="ba-email tool">'; if ($options[0] != '') { $html .= '<label style="font-size:' . $formSettings[1] . '; color:'; $html .= $formSettings[2] . '; font-weight: '; $html .= $formSettings[10] . '"><span title="'; $html .= htmlspecialchars($options[1]) . '">' . htmlspecialchars($options[0]) . '</span></label>'; } $html .= '<input type="email" style="height:' . $formSettings[3] . '; '; $html .= 'font-size:' . $formSettings[4] . ';color:' . $formSettings[5]; $html .= '; background-color:' . $formSettings[6] . '; '; $html .= $formSettings[7] . '; border-radius:' . $formSettings[8] . '"'; $html .= " placeholder='" . htmlspecialchars($options[2], ENT_QUOTES); $html .= "' required"; $html .= " name='"; $html .= $item; $item++; $html .= "'"; $html .= '></div>'; } if ($element[2] == 'textarea') { $options = explode(';', $element[3]); $html .= '<div class="ba-textarea tool">'; if ($options[0] != '') { $html .= '<label style="font-size:' . $formSettings[1] . '; color:'; $html .= $formSettings[2] . '; font-weight: '; $html .= $formSettings[10] . '"><span title="'; $html .= htmlspecialchars($options[1]) . '">' . htmlspecialchars($options[0]); if (isset($options[3])) { if ($options[3] == 1) { $html .= ' *'; } } $html .= '</span></label>'; } $html .= '<textarea style="height:' . $formSettings[3] . '; '; $html .= 'font-size:' . $formSettings[4] . ';color:' . $formSettings[5]; $html .= '; background-color:' . $formSettings[6] . '; '; $html .= $formSettings[7] . '; border-radius:' . $formSettings[8]; $html .= '; min-height:' . $options[4] . 'px;"'; $html .= " placeholder='" . htmlspecialchars($options[2], ENT_QUOTES); $html .= "'"; $html .= " name='"; $html .= $item; $item++; $html .= "'"; if (isset($options[3])) { if ($options[3] == 1) { $html .= ' required'; } } $html .= '></textarea><br></div>'; } if ($element[2] == 'date') { $html .= '<div class="ba-date tool">'; $html .= '<label style="font-size:' . $formSettings[1] . '; color:'; $html .= $formSettings[2] . '; font-weight: '; $html .= $formSettings[10] . '">' . htmlspecialchars($element[3]) . '</label>'; if ($element[3] == '') { $element[3] = 'Date[]'; } $html .= JHTML::calendar(date("Y-m-d"), $item, 'date_' . $id . $k, '%d %B %Y'); $item++; $html .= '</div>'; $k++; } if ($element[2] == 'htmltext') { $item++; $html .= '<div class="ba-htmltext tool">' . $element[3]; $html .= '</div>'; } if ($element[2] == 'chekInline') { $options = explode(';', $element[3]); $html .= '<div class="ba-chekInline tool">'; if ($options[0] != '') { $html .= '<label style="font-size:' . $formSettings[1] . '; color:'; $html .= $formSettings[2] . '; font-weight: '; $html .= $formSettings[10] . '"><span title="'; $html .= htmlspecialchars($options[1]) . '">' . htmlspecialchars($options[0]); if (isset($options[3])) { if ($options[3] == 1) { $html .= ' *'; } } $html .= '</span></label>'; } $option = substr($options[2], 1, strlen($options[2]) - 2); $option = explode('\\n', $option); $html .= '<div class="'; if (isset($options[3])) { if ($options[3] == 1) { $html .= 'required'; } } $html .= '">'; for ($i = 0; $i < count($option); $i++) { $html .= "<span style='font-size:" . $formSettings[4] . "; color:"; $html .= $formSettings[5] . "'><input type='checkbox' name='"; $html .= $item; $html .= "[]' value='"; $html .= htmlspecialchars($option[$i], ENT_QUOTES) . "'"; $html .= '/>' . htmlspecialchars($option[$i]) . '</span>'; } $item++; $html .= '</div></div>'; } if ($element[2] == 'radioInline') { $options = explode(';', $element[3]); $html .= '<div class="ba-radioInline tool">'; if ($options[0] != '') { $html .= '<label style="font-size:' . $formSettings[1] . '; color:'; $html .= $formSettings[2] . '; font-weight: '; $html .= $formSettings[10] . '"><span title="'; $html .= htmlspecialchars($options[1]) . '">' . htmlspecialchars($options[0]); if (isset($options[3])) { if ($options[3] == 1) { $html .= ' *'; } } $html .= '</span></label>'; } $option = substr($options[2], 1, strlen($options[2]) - 2); $option = explode('\\n', $option); for ($i = 0; $i < count($option); $i++) { $html .= "<span style='font-size:" . $formSettings[4] . "; color:"; $html .= $formSettings[5] . "'><input type='radio' name='"; $html .= $item; $html .= "' value='"; $html .= htmlspecialchars($option[$i], ENT_QUOTES) . "'"; if (isset($options[3])) { if ($options[3] == 1 && $i == 0) { $html .= ' required'; } } $html .= '/>' . htmlspecialchars($option[$i]) . '</span>'; } $item++; $html .= '</div>'; } if ($element[2] == 'checkMultiple') { $options = explode(';', $element[3]); $html .= '<div class="ba-checkMultiple tool">'; if ($options[0] != '') { $html .= '<label style="font-size:' . $formSettings[1] . '; color:'; $html .= $formSettings[2] . '; font-weight: '; $html .= $formSettings[10] . '"><span title="'; $html .= htmlspecialchars($options[1]) . '">' . htmlspecialchars($options[0]); if ($options[3] == 1) { $html .= ' *'; } $html .= '</span></label>'; } $option = substr($options[2], 1, strlen($options[2]) - 2); $option = explode('\\n', $option); $html .= '<div class="'; if (isset($options[3])) { if ($options[3] == 1) { $html .= 'required'; } } $html .= '">'; for ($i = 0; $i < count($option); $i++) { $html .= "<span style='font-size:" . $formSettings[4] . "; color:"; $html .= $formSettings[5] . "'><input type='checkbox' name='"; $html .= $item; $html .= "[]' value='"; $html .= htmlspecialchars($option[$i], ENT_QUOTES) . "'"; $html .= '/>' . htmlspecialchars($option[$i]) . '<br></span>'; } $item++; $html .= '</div></div>'; } if ($element[2] == 'upload') { $options = explode(';', $element[3]); $html .= '<div class="ba-upload tool">'; if ($options[0] != '') { $html .= '<label style="font-size:' . $formSettings[1] . '; color:'; $html .= $formSettings[2] . '; font-weight: '; $html .= $formSettings[10] . '"><span title="'; $html .= htmlspecialchars($options[1]) . '">' . htmlspecialchars($options[0]); $html .= '</span></label>'; } $html .= "<input class='ba-upload' type='file'"; $html .= " name='"; $html .= $item; $item++; $html .= "'><br>"; $html .= '<span style="font-size: 12px; font-style:'; $html .= ' italic; color: #999;">' . $language->_('MAXIMUM_FILE_SIZE') . ' ' . $options[2]; $html .= 'mb (' . $options[3] . ')</span>'; $html .= '<input type="hidden" class="upl-size"'; $html .= ' value="' . $options[2] . '">'; $html .= '<input type="hidden" class="upl-type"'; $html .= ' value="' . $options[3] . '">'; $html .= '<input type="hidden" class="upl-error">'; $html .= "</div>"; } if ($element[2] == 'radioMultiple') { $options = explode(';', $element[3]); $html .= '<div class="ba-radioMultiple tool">'; if ($options[0] != '') { $html .= '<label style="font-size:' . $formSettings[1] . '; color:'; $html .= $formSettings[2] . '; font-weight: '; $html .= $formSettings[10] . '"><span title="'; $html .= htmlspecialchars($options[1]) . '">' . htmlspecialchars($options[0]); if (isset($options[3])) { if ($options[3] == 1) { $html .= ' *'; } } $html .= '</span></label>'; } $option = substr($options[2], 1, strlen($options[2]) - 2); $option = explode('\\n', $option); for ($i = 0; $i < count($option); $i++) { $html .= "<span style='font-size:" . $formSettings[4] . "; color:"; $html .= $formSettings[5] . "'><input type='radio' name='"; $html .= $item; $html .= "' value='"; $html .= htmlspecialchars($option[$i], ENT_QUOTES) . "'"; if (isset($options[3])) { if ($options[3] == 1 && $i == 0) { $html .= ' required'; } } $html .= '/>' . htmlspecialchars($option[$i]) . '<br></span>'; } $item++; $html .= '</div>'; } if ($element[2] == 'dropdown') { $options = explode(';', $element[3]); $html .= '<div class="ba-dropdown tool">'; if ($options[0] != '') { $html .= '<label style="font-size:' . $formSettings[1] . '; color:'; $html .= $formSettings[2] . '; font-weight: '; $html .= $formSettings[10] . '"><span title="'; $html .= htmlspecialchars($options[1]) . '">' . htmlspecialchars($options[0]); if (isset($options[3])) { if ($options[3] == 1) { $html .= ' *'; } } $html .= '</span></label>'; } $option = substr($options[2], 1, strlen($options[2]) - 2); $option = explode('\\n', $option); $html .= '<select style="height:' . $formSettings[3] . '; '; $html .= 'font-size:' . $formSettings[4] . ';color:' . $formSettings[5]; $html .= '; background-color:' . $formSettings[6] . '; '; $html .= $formSettings[7] . '"'; $html .= " name='"; $html .= $item; $item++; $html .= "'"; if (isset($options[3])) { if ($options[3] == 1) { $html .= ' required'; } } $html .= '>'; $html .= '<option value="">Select</option>'; for ($i = 0; $i < count($option); $i++) { $html .= '<option value="'; $html .= htmlspecialchars($option[$i], ENT_QUOTES) . '">' . htmlspecialchars($option[$i]) . '</option>'; } $html .= '</select></div>'; } if ($element[2] == 'selectMultiple') { $options = explode(';', $element[3]); $html .= '<div class="ba-selectMultiple tool">'; if ($options[0] != '') { $html .= '<label style="font-size:' . $formSettings[1] . '; color:'; $html .= $formSettings[2] . '; font-weight: '; $html .= $formSettings[10] . '"><span title="'; $html .= htmlspecialchars($options[1]) . '">' . htmlspecialchars($options[0]); if (isset($options[3])) { if ($options[3] == 1) { $html .= ' *'; } } $html .= '</span></label>'; } $option = substr($options[2], 1, strlen($options[2]) - 2); $option = explode('\\n', $option); $html .= '<select multiple size="' . $options[4] . '" style="'; $html .= 'font-size:' . $formSettings[4] . ';color:' . $formSettings[5]; $html .= '; background-color:' . $formSettings[6] . '; '; $html .= $formSettings[7] . '"'; $html .= " name='"; $html .= $item; $item++; $html .= "[]'"; if (isset($options[3])) { if ($options[3] == 1) { $html .= ' required'; } } $html .= '>'; for ($i = 0; $i < count($option); $i++) { $html .= '<option value="'; $html .= htmlspecialchars($option[$i], ENT_QUOTES) . '">' . htmlspecialchars($option[$i]) . '</option>'; } $html .= '</select></div>'; } if ($element[2] == 'map') { $options = explode(';', $element[3]); $html .= '<div><div class="ba-map tool" style="width:' . $options[3]; $html .= '%; height:' . $options[4] . 'px;"></div>'; $html .= "<input type='hidden' value='{$element['3']}' class='ba-options'></div>"; $item++; } if ($element[2] == 'slider') { $options = explode(';', $element[3]); $html .= '<div class="slider tool">'; if ($options[0] != '') { $html .= '<label style="font-size:' . $formSettings[1] . '; color:'; $html .= $formSettings[2] . '; font-weight: '; $html .= $formSettings[10] . '"><span title="'; $html .= htmlspecialchars($options[1]) . '">' . htmlspecialchars($options[0]); $html .= '</span></label>'; } $html .= '<input type="hidden" class="ba-slider-values" '; $html .= " name='"; $html .= $item; $item++; $html .= "'"; $html .= '>'; $html .= '<div class="ba-slider"></div>'; $html .= '<input type="hidden" value="' . htmlspecialchars($element[3]) . '" class="ba-options"></div>'; } } } $html .= '</div>'; } if (trim($column[1]) == 'span12') { $html .= '</div>'; } if (trim($column[1]) == 'span6') { if ($row == 2) { $html .= '</div>'; $row = ''; } } if (trim($column[1]) == 'span4') { if ($row == 3) { $html .= '</div>'; $row = ''; } } if (trim($column[1]) == 'span3') { if ($row == 4) { $html .= '</div>'; $row = ''; } } } $capt = $submissionsOptions['alow_captcha']; if ($capt != '0') { $captcha = JCaptcha::getInstance($capt); $captcha->initialise($capt); $html .= "<div class='tool ba-captcha'>"; $html .= $captcha->display($capt, $capt); $html .= "</div>"; } if ($n != 1) { $html .= '<div class="ba-prev"><input type="button" value="'; $html .= $last[0] . '" style="border-radius:' . $last[7]; $html .= 'px; background-color: #' . $last[3] . '; font-size:'; $html .= $last[5] . 'px; font-weight:' . $last[6] . '; width:'; $html .= $last[1] . 'px; height:' . $last[2] . 'px; color: #' . $last[4]; $html .= '" class="btn-prev"></div>'; } if ($submissionsOptions['display_submit'] == 1) { $html .= '<div class="row-fluid ba-row"><div class="span12" style="' . $buttonAligh . '">'; $html .= '<input class="ba-btn-submit" type="submit" style="' . $buttonStyle; $html .= '" value="' . $button . '" ' . $embed . '>'; $html .= '</div></div>'; } $html .= '</div><input type="hidden" class="redirect" value="'; $html .= $submissionsOptions['redirect_url'] . '">'; $html .= '<input type="hidden" class="sent-massage" value="'; $html .= htmlspecialchars($submissionsOptions['sent_massage']) . '">'; $html .= '<input type="hidden" value="' . JURI::base(); $html .= '" class="admin-dirrectory">'; $html .= '<input type="hidden" name="form_id" value="' . $id . '">'; $html .= '<input type="hidden" name="task" value="form.save">'; $html .= ''; $html .= ''; $html .= ''; $html .= '</div>'; $html .= '</form>'; if ($popup['display_popup'] == 1) { $html .= '</div></div></div>'; } $html .= "</div>"; return $html; }
public function save() { // check for request forgeries $this->app->session->checkToken() or jexit('Invalid Token'); // set currently active author $this->author = $this->app->comment->activeAuthor(); // init vars $redirect = $this->app->request->getString('redirect'); $login = $this->app->request->getCmd(CommentHelper::COOKIE_PREFIX . 'login', '', 'cookie'); if ($this->author->getUserType() == $login) { if ($this->params->get('enable_comments', false)) { // init vars $content = $this->app->request->getVar('content', null, '', 'string', JREQUEST_ALLOWRAW); $item_id = $this->app->request->getInt('item_id', 0); $parent_id = $this->app->request->getInt('parent_id', 0); // filter content $content = $this->app->comment->filterContentInput($content); // set content in session $this->app->session->set('com_zoo.comment.content', $content); // set author name, email and url, if author is guest if ($this->author->isGuest()) { $this->author->name = $this->app->request->getString('author'); $this->author->email = $this->app->request->getString('email'); $this->author->url = $this->app->request->getString('url'); // save cookies $this->app->comment->saveCookies($this->author->name, $this->author->email, $this->author->url); } try { // Check captcha if ($plugin = $this->params->get('captcha', false) and (!$this->params->get('captcha_guest_only', 0) or !$this->app->user->get()->id)) { $captcha = JCaptcha::getInstance($plugin); if (!$captcha->checkAnswer($this->app->request->getString('captcha', ''))) { $error = $captcha->getError(); if (!$error instanceof Exception) { $error = new JException($error); } throw new CommentControllerException(JText::_('ZOO_CHECK_CAPTCHA') . ' - ' . $error); } } // get comment table $table = $this->app->table->comment; // get parent $parent = $table->get($parent_id); $parent_id = $parent && $parent->item_id == $item_id ? $parent->id : 0; // create comment $comment = $this->app->object->create('Comment'); $comment->parent_id = $parent_id; $comment->item_id = $item_id; $comment->ip = $this->app->useragent->ip(); $comment->created = $this->app->date->create()->toSQL(); $comment->content = $content; $comment->state = Comment::STATE_UNAPPROVED; // auto approve comment $approved = $this->params->get('approved', 0); if ($this->author->isJoomlaAdmin()) { $comment->state = Comment::STATE_APPROVED; } else { if ($approved == 1) { $comment->state = Comment::STATE_APPROVED; } else { if ($approved == 2 && $table->getApprovedCommentCount($this->author)) { $comment->state = Comment::STATE_APPROVED; } } } // bind Author $comment->bindAuthor($this->author); // validate comment, if not an administrator if (!$this->author->isJoomlaAdmin()) { $this->_validate($comment); } // save comment $table->save($comment); // remove content from session, if comment was saved $this->app->session->set('com_zoo.comment.content', ''); } catch (CommentControllerException $e) { // raise warning on exception $this->app->error->raiseWarning(0, (string) $e); } catch (AppException $e) { // raise warning on exception $this->app->error->raiseWarning(0, JText::_('ERROR_SAVING_COMMENT')); // add exception details, for super administrators only if ($this->user->superadmin) { $this->app->error->raiseWarning(0, (string) $e); } } // add anchor to redirect, if comment was saved if ($comment->id) { $redirect .= '#comment-' . $comment->id; } } else { // raise warning on comments not enabled $this->app->error->raiseWarning(0, JText::_('Comments are not enabled.')); } } else { // raise warning on exception $this->app->error->raiseWarning(0, JText::_('ERROR_SAVING_COMMENT')); // add exception details, for super administrators only if ($this->user->superadmin) { $this->app->error->raiseWarning(0, JText::_('User types didn\'t match.')); } } $this->setRedirect($redirect); }
/** * function ajax(), executed ajax request * @param JRequest */ public static function ajax($params) { $mainframe = JFactory::getApplication('site'); $session = JFactory::getSession(); $db = JFactory::getDBO(); jimport('joomla.plugin.helper'); jimport('cms.captcha.captcha'); // Initialise variables. $app = JFactory::getApplication(); //load language file $language = JFactory::getLanguage(); $language_tag = $language->getTag(); // loads the current language-tag JFactory::getLanguage()->load('plg_captcha_recaptcha', JPATH_ADMINISTRATOR, $language_tag, true); JFactory::getLanguage()->load('mod_bt_sociallogin', JPATH_SITE, $language_tag, true); JFactory::getLanguage()->load('lib_joomla', JPATH_SITE, $language_tag, true); JFactory::getLanguage()->load('com_users', JPATH_SITE, $language_tag, true); //JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $bttask = JRequest::getVar('bttask'); /** * check task is login to do */ if ($bttask == 'login') { if ($return = JRequest::getVar('return', '', 'method', 'base64')) { $return = base64_decode($return); if (!JURI::isInternal($return)) { $return = ''; } } $options = array(); $options['remember'] = JRequest::getBool('remember', false); $options['return'] = $return; $credentials = array(); $credentials['username'] = JRequest::getVar('username', '', 'method', 'username'); $credentials['password'] = JRequest::getString('passwd', '', 'post', JREQUEST_ALLOWRAW); //preform the login action $error = $mainframe->login($credentials, $options); self::ajaxResponse($error); } elseif ($bttask == 'register') { /** * check task is registration to do */ // If registration is disabled - Redirect to login page. if (JComponentHelper::getParams('com_users')->get('allowUserRegistration') == 0) { self::ajaxResponse("Registration is not allow!"); } //check captcha $enabledRecaptcha = JRequest::getVar('recaptcha'); if ($enabledRecaptcha == 'yes') { if (JRequest::getVar('recaptcha_response_field')) { $plugin = JFactory::getConfig()->get('captcha'); if ($plugin) { $captcha = JCaptcha::getInstance($plugin); if (!$captcha->checkAnswer('')) { self::ajaxResponse('$error$' . JText::_('ERROR_CAPTCHA')); } } } elseif (JRequest::getString('btl_captcha')) { $session = JFactory::getSession(); if (JRequest::getString('btl_captcha') != $session->get('btl_captcha')) { self::ajaxResponse('$error11$' . JText::_('INCORRECT_CAPTCHA')); } } else { self::ajaxResponse('$error5$' . JText::_('INCORRECT_CAPTCHA')); } } // Get the user data. $postData = JRequest::getVar('jform'); $requestData = $postData; if (isset($requestData['profile']['dob'])) { $requestData['profile']['dob'] = date('m/d/Y h:i:s', strtotime($requestData['profile']['dob'])); } //check type registration $userInfo = $session->get('btl-u'); $regtype = isset($userInfo['loginType']) ? $userInfo['loginType'] : ''; //preview data form social if ($regtype) { if (!$params->get('edit_email_' . $regtype)) { // don't alow changing user email $requestData['email1'] = $userInfo['email1']; $requestData['email2'] = $userInfo['email1']; } $return = self::registerSocial($requestData); if ($return == false) { self::ajaxResponse('$error$' . JText::_('REGISTRATION_FALSE')); } else { self::unblockUser($requestData['email1']); self::loginSocial($requestData['email1']); self::ajaxResponse(JText::_('REGISTRATION_AND_AUTOLOGIN')); $session->clear('btl-u'); } } else { $return = self::register($requestData); if ($return === 'adminactivate') { self::ajaxResponse(JText::_('COM_USERS_REGISTRATION_COMPLETE_VERIFY')); } elseif ($return === 'useractivate') { self::ajaxResponse(JText::_('COM_USERS_REGISTRATION_COMPLETE_ACTIVATE')); } elseif ($return == false) { self::ajaxResponse('Cannot Registration!'); } else { self::ajaxResponse(JText::_('COM_USERS_REGISTRATION_SAVE_SUCCESS')); } } } else { self::ajaxResponse(self::createCaptcha()); } }
/** * Creates the item submit form * * @since 1.0 */ function _displayForm($tpl) { jimport('joomla.html.parameter'); // ... we use some strings from administrator part // load english language file for 'com_content' component then override with current language file JFactory::getLanguage()->load('com_content', JPATH_ADMINISTRATOR, 'en-GB', true); JFactory::getLanguage()->load('com_content', JPATH_ADMINISTRATOR, null, true); // load english language file for 'com_flexicontent' component then override with current language file JFactory::getLanguage()->load('com_flexicontent', JPATH_ADMINISTRATOR, 'en-GB', true); JFactory::getLanguage()->load('com_flexicontent', JPATH_ADMINISTRATOR, null, true); // ******************************** // Initialize variables, flags, etc // ******************************** $app = JFactory::getApplication(); $dispatcher = JDispatcher::getInstance(); $document = JFactory::getDocument(); $session = JFactory::getSession(); $user = JFactory::getUser(); $db = JFactory::getDBO(); $uri = JFactory::getURI(); $nullDate = $db->getNullDate(); $menu = $app->getMenu()->getActive(); // We do not have item parameters yet, but we need to do some work before creating the item // Get the COMPONENT only parameter $params = new JRegistry(); $cparams = JComponentHelper::getParams('com_flexicontent'); $params->merge($cparams); // Merge the active menu parameters if ($menu) { $params->merge($menu->params); } // Some flags $enable_translation_groups = flexicontent_db::useAssociations(); //$params->get("enable_translation_groups"); $print_logging_info = $params->get('print_logging_info'); if ($print_logging_info) { global $fc_run_times; } // ***************** // Load JS/CSS files // ***************** FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools'); flexicontent_html::loadFramework('jQuery'); flexicontent_html::loadFramework('select2'); flexicontent_html::loadFramework('flexi-lib'); // Load custom behaviours: form validation, popup tooltips JHTML::_('behavior.formvalidation'); // load default validation JS to make sure it is overriden JHTML::_('behavior.tooltip'); if (FLEXI_J30GE) { JHtml::_('bootstrap.tooltip'); } //JHTML::_('script', 'joomla.javascript.js', 'includes/js/'); // Add css files to the document <head> section (also load CSS joomla template override) $document->addStyleSheet(JURI::base(true) . '/components/com_flexicontent/assets/css/flexicontent.css'); if (file_exists(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'css' . DS . 'flexicontent.css')) { $document->addStyleSheet($this->baseurl . '/templates/' . $app->getTemplate() . '/css/flexicontent.css'); } // Fields common CSS $document->addStyleSheet($this->baseurl . '/components/com_flexicontent/assets/css/flexi_form_fields.css'); // Load backend / frontend shared and Joomla version specific CSS (different for frontend / backend) FLEXI_J30GE ? $document->addStyleSheet(JURI::base(true) . '/components/com_flexicontent/assets/css/j3x.css') : $document->addStyleSheet(JURI::base(true) . '/components/com_flexicontent/assets/css/j25.css'); // Add js function to overload the joomla submitform $document->addScript(JURI::base(true) . '/components/com_flexicontent/assets/js/admin.js'); $document->addScript(JURI::base(true) . '/components/com_flexicontent/assets/js/validate.js'); // Add js function for custom code used by FLEXIcontent item form $document->addScript(JURI::base(true) . '/components/com_flexicontent/assets/js/itemscreen.js'); // ********************************************************* // Get item data and create item form (that loads item data) // ********************************************************* if ($print_logging_info) { $start_microtime = microtime(true); } $model = $this->getModel(); // ** WE NEED TO get OR decide the Content Type, before we call the getItem // ** We rely on typeid Request variable to decide type for new items so make sure this is set, // ZERO means allow user to select type, but if user is only allowed a single type, then autoselect it! // Try type from session $jdata = $app->getUserState('com_flexicontent.edit.item.data'); //print_r($jdata); if (!empty($jdata['type_id'])) { JRequest::setVar('typeid', (int) $jdata['type_id']); // This also forces zero if value not set } else { if ($menu && isset($menu->query['typeid'])) { JRequest::setVar('typeid', (int) $menu->query['typeid']); // This also forces zero if value not set } } $new_typeid = JRequest::getVar('typeid', 0, '', 'int'); // Verify type is allowed to the user if (!$new_typeid) { $types = $model->getTypeslist($type_ids_arr = false, $check_perms = true, $_published = true); if ($types && count($types) == 1) { $new_typeid = $types[0]->id; } JRequest::setVar('typeid', $new_typeid); $canCreateType = true; } // FORCE model to load versioned data (URL specified version or latest version (last saved)) $version = JRequest::getVar('version', 0, 'request', 'int'); // Load specific item version (non-zero), 0 version: is unversioned data, -1 version: is latest version (=default for edit form) $item = $model->getItem(null, $check_view_access = false, $no_cache = true, $force_version = $version != 0 ? $version : -1); // -1 version means latest // Replace component/menu 'params' with thee merged component/category/type/item/menu ETC ... parameters $params =& $item->parameters; if ($print_logging_info) { $fc_run_times['get_item_data'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; } // Load permissions (used by form template) $perms = $this->_getItemPerms($item); // Create submit configuration (for new items) into the session, this is needed before creating the item form $submitConf = $this->_createSubmitConf($item, $perms); // Most core field are created via calling methods of the form (J2.5) $form = $this->get('Form'); // is new item and ownership Flags $isnew = !$item->id; $isOwner = $item->created_by == $user->get('id'); // Get available types and the currently selected/requested type $types = $model->getTypeslist(); $typesselected = $model->getTypesselected(); // Get type parameters, these are needed besides the 'merged' item parameters, e.g. to get Type's default layout $tparams = $this->get('Typeparams'); $tparams = new JRegistry($tparams); // ********************************************************************************************************* // Get language stuff, and also load Template-Specific language file to override or add new language strings // ********************************************************************************************************* if ($enable_translation_groups) { $langAssocs = $params->get('uselang_fe') == 1 ? $this->get('LangAssocs') : false; } $langs = FLEXIUtilities::getLanguages('code'); FLEXIUtilities::loadTemplateLanguageFile($params->get('ilayout', 'default')); // ************************************* // Create captcha field via custom logic // ************************************* // create and set (into HTTP request) a unique item id for plugins that needed it if ($item->id) { $unique_tmp_itemid = $item->id; } else { $unique_tmp_itemid = $app->getUserState('com_flexicontent.edit.item.unique_tmp_itemid'); $unique_tmp_itemid = $unique_tmp_itemid ? $unique_tmp_itemid : date('_Y_m_d_h_i_s_', time()) . uniqid(true); } //print_r($unique_tmp_itemid); JRequest::setVar('unique_tmp_itemid', $unique_tmp_itemid); // Component / Menu Item parameters $allowunauthorize = $params->get('allowunauthorize', 0); // allow unauthorised user to submit new content $unauthorized_page = $params->get('unauthorized_page', ''); // page URL for unauthorized users (via global configuration) $notauth_itemid = $params->get('notauthurl', ''); // menu itemid (to redirect) when user is not authorized to create content // Create captcha field or messages // Maybe some code can be removed by using Joomla's built-in form element (in XML file), instead of calling the captcha plugin ourselves $use_captcha = $params->get('use_captcha', 1); // 1 for guests, 2 for any user $captcha_formop = $params->get('captcha_formop', 0); // 0 for submit, 1 for submit/edit (aka always) $display_captcha = $use_captcha >= 2 || $use_captcha == 1 && $user->guest; $display_captcha = $display_captcha && ($isnew || $captcha_formop); // Trigger the configured captcha plugin if ($display_captcha) { // Get configured captcha plugin $c_plugin = $params->get('captcha', $app->getCfg('captcha')); // TODO add param to override default if ($c_plugin) { $c_name = 'captcha_response_field'; $c_id = $c_plugin == 'recaptcha' ? 'dynamic_recaptcha_1' : 'fc_dynamic_captcha'; $c_class = ' required'; $c_namespace = 'fc_item_form'; // Try to load the configured captcha plugin, (check if disabled or uninstalled), Joomla will enqueue an error message if needed $captcha_obj = JCaptcha::getInstance($c_plugin, array('namespace' => $c_namespace)); if ($captcha_obj) { $captcha_field = $captcha_obj->display($c_name, $c_id, $c_class); $label_class = 'flexi_label'; $label_class .= FLEXI_J30GE ? ' hasTooltip' : ' hasTip'; $label_tooltip = flexicontent_html::getToolTip(null, 'FLEXI_CAPTCHA_ENTER_CODE_DESC', 1, 1); $captcha_field = ' <label id="' . $c_name . '-lbl" for="' . $c_name . '" class="' . $label_class . '" title="' . $label_tooltip . '" > ' . JText::_('FLEXI_CAPTCHA_ENTER_CODE') . ' </label> <div id="container_fcfield_' . $c_plugin . '" class="container_fcfield container_fcfield_name_' . $c_plugin . '"> <div class="fcfieldval_container valuebox fcfieldval_container_' . $c_plugin . '"> ' . $captcha_field . ' </div> </div>'; } } } // ******************************* // CHECK EDIT / CREATE PERMISSIONS // ******************************* // User Group / Author parameters $authorparams = flexicontent_db::getUserConfig($user->id); $max_auth_limit = intval($authorparams->get('max_auth_limit', 0)); // maximum number of content items the user can create $hasTmpEdit = false; $hasCoupon = false; // Check session if ($session->has('rendered_uneditable', 'flexicontent')) { $rendered_uneditable = $session->get('rendered_uneditable', array(), 'flexicontent'); $hasTmpEdit = !empty($rendered_uneditable[$model->get('id')]); $hasCoupon = !empty($rendered_uneditable[$model->get('id')]) && $rendered_uneditable[$model->get('id')] == 2; // editable via coupon } if (!$isnew) { // EDIT action // Finally check if item is currently being checked-out (currently being edited) if ($model->isCheckedOut($user->get('id'))) { $msg = JText::sprintf('FLEXI_DESCBEINGEDITTED', $model->get('title')); $app->redirect(JRoute::_('index.php?view=' . FLEXI_ITEMVIEW . '&cid=' . $model->get('catid') . '&id=' . $model->get('id'), false), $msg); } //Checkout the item $model->checkout(); // Get edit access, this includes privileges edit and edit-own and the temporary EDIT flag ('rendered_uneditable') $canEdit = $model->getItemAccess()->get('access-edit'); // If no edit privilege, check if edit COUPON was provided if (!$canEdit) { $edittok = JRequest::getCmd('edittok', false); if ($edittok) { $query = 'SHOW TABLES LIKE "' . $app->getCfg('dbprefix') . 'flexicontent_edit_coupons"'; $db->setQuery($query); $tbl_exists = (bool) count($db->loadObjectList()); if ($tbl_exists) { $query = 'SELECT * FROM #__flexicontent_edit_coupons ' . ' WHERE token = ' . $db->Quote($edittok) . ' AND id = ' . $model->get('id'); $db->setQuery($query); $tokdata = $db->loadObject(); if ($tokdata) { $hasCoupon = true; $rendered_uneditable = $session->get('rendered_uneditable', array(), 'flexicontent'); $rendered_uneditable[$model->get('id')] = 2; // 2: indicates, that has edit via EDIT Coupon $session->set('rendered_uneditable', $rendered_uneditable, 'flexicontent'); $canEdit = 1; } else { JError::raiseNotice(403, JText::_('EDIT_TOKEN_IS_INVALID') . ' : ' . $edittok); } } } } // Edit check finished, throw error if needed if (!$canEdit) { if ($user->guest) { $uri = JFactory::getURI(); $return = $uri->toString(); $fcreturn = serialize(array('id' => @$this->_item->id, 'cid' => $cid)); // a special url parameter, used by some SEF code $com_users = FLEXI_J16GE ? 'com_users' : 'com_user'; $url = $params->get('login_page', 'index.php?option=' . $com_users . '&view=login'); $return = strtr(base64_encode($return), '+/=', '-_,'); $url .= '&return=' . $return; //$url .= '&return='.urlencode(base64_encode($return)); $url .= '&fcreturn=' . base64_encode($fcreturn); JError::raiseWarning(403, JText::sprintf("FLEXI_LOGIN_TO_ACCESS", $url)); $app->redirect($url); } else { if ($unauthorized_page) { // unauthorized page via global configuration JError::raiseNotice(403, JText::_('FLEXI_ALERTNOTAUTH_TASK')); $app->redirect($unauthorized_page); } else { // user isn't authorize to edit this content $msg = JText::_('FLEXI_ALERTNOTAUTH_TASK'); if (FLEXI_J16GE) { throw new Exception($msg, 403); } else { JError::raiseError(403, $msg); } } } } } else { // CREATE action // Get create access, this includes check of creating in at least one category, and type's "create items" $canAdd = $model->getItemAccess()->get('access-create'); $not_authorised = !$canAdd; // Check if Content Type can be created by current user if (empty($canCreateType)) { if ($new_typeid) { // not needed, already done be model when type_id is set, check and remove $canCreateType = $model->canCreateType(array($new_typeid)); // Can create given Content Type } else { // needed not done be model yet $canCreateType = $model->canCreateType(); // Can create at least one Content Type } } $not_authorised = $not_authorised || !$canCreateType; // Allow item submission by unauthorized users, ... even guests ... if ($allowunauthorize == 2) { $allowunauthorize = !$user->guest; } if ($not_authorised && !$allowunauthorize) { if (!$canCreateType) { $type_name = isset($types[$new_typeid]) ? '"' . JText::_($types[$new_typeid]->name) . '"' : JText::_('FLEXI_ANY'); $msg = JText::sprintf('FLEXI_NO_ACCESS_CREATE_CONTENT_OF_TYPE', $type_name); } else { $msg = JText::_('FLEXI_ALERTNOTAUTH_CREATE'); } } else { if ($max_auth_limit) { $db->setQuery('SELECT COUNT(id) FROM #__content WHERE created_by = ' . $user->id); $authored_count = $db->loadResult(); $content_is_limited = $authored_count >= $max_auth_limit; $msg = $content_is_limited ? JText::sprintf('FLEXI_ALERTNOTAUTH_CREATE_MORE', $max_auth_limit) : ''; } } if ($not_authorised && !$allowunauthorize || @$content_is_limited) { // User isn't authorize to add ANY content if ($notauth_menu = $app->getMenu()->getItem($notauth_itemid)) { // a. custom unauthorized submission page via menu item $internal_link_vars = @$notauth_menu->component ? '&Itemid=' . $notauth_itemid . '&option=' . $notauth_menu->component : ''; $notauthurl = JRoute::_($notauth_menu->link . $internal_link_vars, false); JError::raiseNotice(403, $msg); $app->redirect($notauthurl); } else { if ($unauthorized_page) { // b. General unauthorized page via global configuration JError::raiseNotice(403, $msg); $app->redirect($unauthorized_page); } else { // c. Finally fallback to raising a 403 Exception/Error that will redirect to site's default 403 unauthorized page if (FLEXI_J16GE) { throw new Exception($msg, 403); } else { JError::raiseError(403, $msg); } } } } } // ***************************************************************************** // Get (CORE & CUSTOM) fields and their VERSIONED values and then // (a) Apply Content Type Customization to CORE fields (label, description, etc) // (b) Create the edit html of the CUSTOM fields by triggering 'onDisplayField' // ***************************************************************************** // Check if saving an item that translates an original content in site's default language $site_default = substr(flexicontent_html::getSiteDefaultLang(), 0, 2); $is_content_default_lang = $site_default == substr($item->language, 0, 2); //$modify_untraslatable_values = $enable_translation_groups && !$is_content_default_lang; // && $item->lang_parent_id && $item->lang_parent_id!=$item->id; if ($print_logging_info) { $start_microtime = microtime(true); } $fields = $this->get('Extrafields'); $item->fields =& $fields; if ($print_logging_info) { $fc_run_times['get_field_vals'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; } if ($print_logging_info) { $start_microtime = microtime(true); } $jcustom = $app->getUserState('com_flexicontent.edit.item.custom'); //print_r($jcustom); foreach ($fields as $field) { // a. Apply CONTENT TYPE customizations to CORE FIELDS, e.g a type specific label & description // NOTE: the field parameters are already created so there is not need to call this for CUSTOM fields, which do not have CONTENT TYPE customizations if ($field->iscore) { FlexicontentFields::loadFieldConfig($field, $item); } // b. Create field 's editing HTML (the form field) // NOTE: this is DONE only for CUSTOM fields, since form field html is created by the form for all CORE fields, EXCEPTION is the 'text' field (see bellow) if (!$field->iscore) { if (isset($jcustom[$field->name])) { $field->value = array(); foreach ($jcustom[$field->name] as $i => $_val) { $field->value[$i] = $_val; } } $is_editable = !$field->valueseditable || $user->authorise('flexicontent.editfieldvalues', 'com_flexicontent.field.' . $field->id); if ($is_editable) { FLEXIUtilities::call_FC_Field_Func($field->field_type, 'onDisplayField', array(&$field, &$item)); if ($field->untranslatable) { $field->html = '<div class="alert alert-info fc-small fc-iblock">' . JText::_('FLEXI_FIELD_VALUE_IS_NON_TRANSLATABLE') . '</div>' . "\n" . $field->html; } } else { if ($field->valueseditable == 1) { $field->html = '<div class="fc-mssg fc-note">' . JText::_($field->parameters->get('no_acc_msg_form') ? $field->parameters->get('no_acc_msg_form') : 'FLEXI_NO_ACCESS_LEVEL_TO_EDIT_FIELD') . '</div>'; } else { if ($field->valueseditable == 2) { FLEXIUtilities::call_FC_Field_Func($field->field_type, 'onDisplayFieldValue', array(&$field, $item)); $field->html = '<div class="fc-mssg fc-note">' . JText::_($field->parameters->get('no_acc_msg_form') ? $field->parameters->get('no_acc_msg_form') : 'FLEXI_NO_ACCESS_LEVEL_TO_EDIT_FIELD') . '</div>' . "\n" . $field->display; } else { if ($field->valueseditable == 3) { FLEXIUtilities::call_FC_Field_Func($field->field_type, 'onDisplayFieldValue', array(&$field, $item)); $field->html = $field->display; } else { if ($field->valueseditable == 4) { $field->html = ''; $field->formhidden = 4; } } } } } } // c. Create main text field, via calling the display function of the textarea field (will also check for tabs) if ($field->field_type == 'maintext') { if (isset($item->item_translations)) { $shortcode = substr($item->language, 0, 2); foreach ($item->item_translations as $lang_id => $t) { if ($shortcode == $t->shortcode) { continue; } $field->name = array('jfdata', $t->shortcode, 'text'); $field->value[0] = html_entity_decode($t->fields->text->value, ENT_QUOTES, 'UTF-8'); FLEXIUtilities::call_FC_Field_Func('textarea', 'onDisplayField', array(&$field, &$item)); $t->fields->text->tab_labels = $field->tab_labels; $t->fields->text->html = $field->html; unset($field->tab_labels); unset($field->html); } } $field->name = 'text'; // NOTE: We use the text created by the model and not the text retrieved by the CORE plugin code, which maybe overwritten with JoomFish/Falang data $field->value[0] = $item->text; // do not decode special characters this was handled during saving ! // Render the field's (form) HTML FLEXIUtilities::call_FC_Field_Func('textarea', 'onDisplayField', array(&$field, &$item)); } } if ($print_logging_info) { $fc_run_times['render_field_html'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; } // Tags used by the item $usedtagsids = $this->get('UsedtagsIds'); // NOTE: This will normally return the already set versioned value of tags ($item->tags) $usedtagsdata = $model->getUsedtagsData($usedtagsids); // Get the edit lists $lists = $this->_buildEditLists($perms, $params, $authorparams); // Get number of subscribers $subscribers = $this->get('SubscribersCount'); // Get menu overridden categories/main category fields $menuCats = $this->_getMenuCats($item, $perms); // Create placement configuration for CORE properties $placementConf = $this->_createPlacementConf($item, $fields); // Item language related vars $languages = FLEXIUtilities::getLanguages(); $itemlang = new stdClass(); $itemlang->shortcode = substr($item->language, 0, 2); $itemlang->name = $languages->{$item->language}->name; $itemlang->image = '<img src="' . @$languages->{$item->language}->imgsrc . '" alt="' . $languages->{$item->language}->name . '" />'; //Load the JEditor object $editor = JFactory::getEditor(); // ********************************************************** // Calculate a (browser window) page title and a page heading // ********************************************************** // Verify menu item points to current FLEXIcontent object if ($menu) { $menu_matches = false; $view_ok = FLEXI_ITEMVIEW == @$menu->query['view'] || 'article' == @$menu->query['view']; $menu_matches = $view_ok; //$menu_params = $menu->params; // Get active menu item parameters } else { $menu_matches = false; } // MENU ITEM matched, use its page heading (but use menu title if the former is not set) if ($menu_matches) { $default_heading = FLEXI_J16GE ? $menu->title : $menu->name; // Cross set (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template) $params->def('page_heading', $params->get('page_title', $default_heading)); $params->def('page_title', $params->get('page_heading', $default_heading)); $params->def('show_page_heading', $params->get('show_page_title', 0)); $params->def('show_page_title', $params->get('show_page_heading', 0)); } else { // Calculate default page heading (=called page title in J1.5), which in turn will be document title below !! ... $default_heading = !$isnew ? JText::_('FLEXI_EDIT') : JText::_('FLEXI_NEW'); // Decide to show page heading (=J1.5 page title), there is no need for this in item view $show_default_heading = 0; // Set both (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template) $params->set('page_title', $default_heading); $params->set('page_heading', $default_heading); $params->set('show_page_heading', $show_default_heading); $params->set('show_page_title', $show_default_heading); } // ************************************************************ // Create the document title, by from page title and other data // ************************************************************ // Use the page heading as document title, (already calculated above via 'appropriate' logic ...) $doc_title = $params->get('page_title'); // Check and prepend or append site name // Add Site Name to page title if ($app->getCfg('sitename_pagetitles', 0) == 1) { $doc_title = $app->getCfg('sitename') . " - " . $doc_title; } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) { $doc_title = $doc_title . " - " . $app->getCfg('sitename'); } // Finally, set document title $document->setTitle($doc_title); // Add title to pathway $pathway = $app->getPathWay(); $pathway->addItem($doc_title, ''); // Get pageclass suffix $pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); // Ensure the row data is safe html // @TODO: check if this is really required as it conflicts with the escape function in the tmpl //JFilterOutput::objectHTMLSafe( $item ); $this->assign('action', $uri->toString()); $this->assignRef('item', $item); $this->assignRef('form', $form); // most core field are created via calling methods of the form (J2.5) if ($enable_translation_groups) { $this->assignRef('lang_assocs', $langAssocs); } $this->assignRef('langs', $langs); $this->assignRef('params', $params); $this->assignRef('lists', $lists); $this->assignRef('subscribers', $subscribers); $this->assignRef('editor', $editor); $this->assignRef('user', $user); $this->assignRef('usedtagsdata', $usedtagsdata); $this->assignRef('fields', $fields); $this->assignRef('tparams', $tparams); $this->assignRef('perms', $perms); $this->assignRef('document', $document); $this->assignRef('nullDate', $nullDate); $this->assignRef('menuCats', $menuCats); $this->assignRef('submitConf', $submitConf); $this->assignRef('placementConf', $placementConf); $this->assignRef('itemlang', $itemlang); $this->assignRef('pageclass_sfx', $pageclass_sfx); $this->assign('captcha_errmsg', @$captcha_errmsg); $this->assign('captcha_field', @$captcha_field); // **************************************************************** // SET INTO THE FORM, parameter values for various parameter groups // **************************************************************** if (JHTML::_('date', $item->publish_down, 'Y') <= 1969 || $item->publish_down == $nullDate) { $item->publish_down = JText::_('FLEXI_NEVER'); } // **************************** // Handle Template related work // **************************** // (a) Get the templates structures used to create form fields for template parameters $themes = flexicontent_tmpl::getTemplates(); $tmpls_all = $themes->items; // (b) Get Content Type allowed templates $allowed_tmpls = $tparams->get('allowed_ilayouts'); $type_default_layout = $tparams->get('ilayout', 'default'); if (empty($allowed_tmpls)) { $allowed_tmpls = array(); } if (!is_array($allowed_tmpls)) { $allowed_tmpls = explode("|", $allowed_tmpls); } // (c) Add default layout, unless all templates allowed (=array is empty) if (count($allowed_tmpls) && !in_array($type_default_layout, $allowed_tmpls)) { $allowed_tmpls[] = $type_default_layout; } // (d) Create array of template data according to the allowed templates for current content type if (count($allowed_tmpls)) { foreach ($tmpls_all as $tmpl) { if (in_array($tmpl->name, $allowed_tmpls)) { $tmpls[] = $tmpl; } } } else { $tmpls = $tmpls_all; } // (e) Apply Template Parameters values into the form fields structures foreach ($tmpls as $tmpl) { if (FLEXI_J16GE) { $jform = new JForm('com_flexicontent.template.item', array('control' => 'jform', 'load_data' => true)); $jform->load($tmpl->params); $tmpl->params = $jform; foreach ($tmpl->params->getGroup('attribs') as $field) { $fieldname = $field->__get('fieldname'); $value = $item->itemparams->get($fieldname); if (strlen($value)) { $tmpl->params->setValue($fieldname, 'attribs', $value); } } } else { $tmpl->params->loadINI($item->attribs); } } $this->assignRef('tmpls', $tmpls); // Clear custom form data from session $app->setUserState($form->option . '.edit.' . $form->context . '.custom', false); $app->setUserState($form->option . '.edit.' . $form->context . '.jfdata', false); $app->setUserState($form->option . '.edit.' . $form->context . '.unique_tmp_itemid', false); if ($print_logging_info) { $start_microtime = microtime(true); } parent::display($tpl); if ($print_logging_info) { $fc_run_times['form_rendering'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; } }
$effect = 'btl-dropdown'; } else { $effect = 'btl-modal'; } //setting for registration $usersConfig = JComponentHelper::getParams('com_users'); $enabledRegistration = false; $viewName = JRequest::getVar('view', 'registry'); $enabledRecaptcha = 'none'; if ($usersConfig->get('allowUserRegistration') && $params->get("enabled_registration_tab", 1) == 1 && $viewName != "registration") { $enabledRegistration = true; $enabledRecaptcha = $usersConfig->get('captcha') ? $usersConfig->get('captcha') : JFactory::getConfig()->get('captcha'); if ($enabledRecaptcha == 'recaptcha' && $user->id == 0) { // create instance captcha, get recaptcha $recaptchaPlg = JPluginHelper::getPlugin('captcha', 'recaptcha'); $recaptchaPlgParams = new JRegistry($recaptchaPlg->params); $publicKey = $recaptchaPlgParams->get('public_key'); $reCaptcha = ''; if ($publicKey) { $captcha = JCaptcha::getInstance('recaptcha'); $reCaptcha = $captcha->display($publicKey, 'btrecaptcha'); } } } $language = JFactory::getLanguage(); $avatar = modbt_socialconnectHelper::getAvatar($user->id); $user_fields = modbt_socialconnectHelper::loadUserFields(); require JModuleHelper::getLayoutPath('mod_btsocialconnect_login', $params->get('layout', 'default')); ?>
public function save($data) { $itemName = 0; $id = $data['form_id']; $flag = true; $email = ''; $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select("title, alow_captcha, sent_massage, error_massage"); $query->from("#__baforms_forms"); $query->where("id=" . $id); $db->setQuery($query); $form = $db->loadAssoc(); $title = $form['title']; $capt = $form['alow_captcha']; $succes = $form['sent_massage']; $error = $form['error_massage']; $submissionData = ''; $query = $db->getQuery(true); $query->select('settings')->from('#__baforms_items')->where('form_id=' . $id); $db->setQuery($query); $items = $db->loadObjectList(); $captName = array(); if ($capt != '0') { $captcha = JCaptcha::getInstance($capt, array('namespace' => 'anything')); if (isset($data[$capt])) { $answer = $captcha->checkAnswer($data[$capt]); if ($answer) { $flag = true; } else { $flag = false; } } else { foreach ($data as $key => $dat) { if ($key != 'task' && $key != 'form_id') { array_push($captName, $key); } } foreach ($items as $key => $item) { $item = $itemName; $itemName++; for ($i = 0; $i < count($captName); $i++) { if ($item == $captName[$i]) { unset($captName[$i]); sort($captName); } } } $itemName = 0; if (isset($captName[0])) { $answer = $captcha->checkAnswer($data[$captName[0]]); } else { $answer = $captcha->checkAnswer('anything'); } if ($answer) { $flag = true; } else { $flag = false; } } } if ($flag) { foreach ($items as $item) { if ($flag) { $itm = explode('_-_', $item->settings); $type = trim($itm[2]); $itm = explode(';', $itm[3]); if ($type == 'textarea' || $type == 'textInput' || $type == 'chekInline' || $type == 'checkMultiple' || $type == 'radioInline' || $type == 'radioMultiple' || $type == 'dropdown' || $type == 'selectMultiple') { $required = $itm[3]; $itm = trim($this->checkItems($itm[0], $type, $itm[2])); $name = $itm; $itm = str_replace(' ', '_', $itm); if ($required == 1) { if (!empty($data[$itemName])) { $flag = true; } else { $flag = false; } } else { $flag = true; } } else { if ($type == 'email') { $itm = trim($this->checkItems($itm[0], $type, $itm[2])); $name = $itm; $itm = str_replace(' ', '_', $itm); if (!empty($data[$itemName]) && preg_match("/^\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,6})+\$/", $data[$itemName])) { $email = $data[$itemName]; $flag = true; } else { $flag = false; } } else { $itm = trim($this->checkItems($itm[0], $type, '')); $name = $itm; $itm = str_replace(' ', '_', $itm); } } if ($flag) { foreach ($data as $key => $item) { if ($key != "form_id" && $key != "task") { if ($itemName != 0) { if ($itemName == $key) { if (is_array($item)) { $message = ''; foreach ($item as $element) { $message .= strip_tags($element) . ';'; } $submissionData .= $name . '|-_-|' . $message . '|-_-|' . $type . '_-_'; } else { $submissionData .= $name . '|-_-|' . strip_tags($item) . '|-_-|' . $type . '_-_'; } } } } } } $itemName++; } } if ($flag) { if (!empty($_FILES)) { foreach ($_FILES as $key => $file) { if ($file['error'] == 0 && $flag) { $k = 0; foreach ($items as $item) { if ($key == $k) { $options = $item->settings; $options = explode('_-_', $options); $type = trim($options[2]); $options = explode(';', $options[3]); $link = $this->saveUpload($key, $options[2], $options[3], $id); if ($link) { $key = str_replace('_', ' ', $key); $submissionData .= $options[0] . '|-_-|' . $link . '|-_-|' . $type . '_-_'; } else { $flag = false; } $k++; } else { $k++; } } } } } } if ($flag) { $columns = array('title, mesage, date_time'); $date = date('Y-m-d'); $values = array($db->quote($title), $db->quote($submissionData), $db->quote($date)); $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->insert('#__baforms_submissions'); $query->columns($columns); $query->values(implode(',', $values)); $db->setQuery($query); $db->execute(); $this->sendEmail($title, $submissionData, $id, $email); echo '<input id="form-sys-mesage" type="hidden" value="' . htmlspecialchars($succes, ENT_QUOTES) . '">'; } else { echo '<input id="form-sys-mesage" type="hidden" value="' . htmlspecialchars($error, ENT_QUOTES) . '">'; } } else { echo '<input id="form-sys-mesage" type="hidden" value="' . htmlspecialchars($error, ENT_QUOTES) . '">'; } ?> <script language="JavaScript"> var intervalId = setInterval(sec,12); function sec() { var msg = document.getElementById("form-sys-mesage").value; if (msg) { clearInterval(intervalId); window.parent.postMessage(msg, "*"); } } </script> <?php exit; }
public static function createCaptcha($params, $name, $id, $class = '') { $plugin = self::getCaptchaPlugin($params); if (!$plugin) { return ''; } else { $captcha = JCaptcha::getInstance($plugin); if ($captcha == null) { return ''; } } return $captcha->display($name, $id, $class); }
/** * Logic to save an item * * @access public * @return void * @since 1.0 */ function save() { // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); //echo '<html> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <body>'; // Initialize variables $app = JFactory::getApplication(); $db = JFactory::getDBO(); $user = JFactory::getUser(); $config = JFactory::getConfig(); $session = JFactory::getSession(); $task = JRequest::getVar('task'); $ctrl_task = 'task=items.'; // ********************* // Get data from request // ********************* // Retrieve form data these are subject to basic filtering $data = JRequest::getVar('jform', array(), 'post', 'array'); // Core Fields and and item Parameters $custom = JRequest::getVar('custom', array(), 'post', 'array'); // Custom Fields $jfdata = JRequest::getVar('jfdata', array(), 'post', 'array'); // Joomfish Data // Set into model: id (needed for loading correct item), and type id (e.g. needed for getting correct type parameters for new items) $data_id = (int) $data['id']; $isnew = $data_id == 0; // If new make sure that type id is set too, before creating the model if ($isnew) { $typeid = JRequest::setvar('typeid', (int) @$data['type_id']); } // Get the model $model = $this->getModel('item'); $model->setId($data_id); // Make sure id is correct // Get some flags this will also trigger item loading if not already loaded $isOwner = $model->get('created_by') == $user->get('id'); // Get merged parameters: component, type, menu $params = new JRegistry(); $model_params = $model->getComponentTypeParams(); $params->merge($model_params); // Merge the active menu parameters $menu = $app->getMenu()->getActive(); if ($menu) { $params->merge($menu->params); } // Get some needed parameters $submit_redirect_url_fe = $params->get('submit_redirect_url_fe', ''); $allowunauthorize = $params->get('allowunauthorize', 0); $dolog = $params->get('print_logging_info'); // Unique id for new items, needed by some fields for temporary data $unique_tmp_itemid = JRequest::getVar('unique_tmp_itemid'); // Auto title for some content types if ($params->get('auto_title', 0)) { $data['title'] = (int) $data['id']; } // item id or ZERO for new items if (!@$data['rules']) { $data['rules'] = array(); } // We use some strings from administrator part, load english language file // for 'com_flexicontent' component then override with current language file JFactory::getLanguage()->load('com_flexicontent', JPATH_ADMINISTRATOR, 'en-GB', true); JFactory::getLanguage()->load('com_flexicontent', JPATH_ADMINISTRATOR, null, true); // ************************************* // ENFORCE can change category ACL perms // ************************************* $perms = FlexicontentHelperPerm::getPerm(); // Per content type change category permissions $current_type_id = $isnew || !$model->get('type_id') ? (int) @$data['type_id'] : $model->get('type_id'); // GET current (existing/old) item TYPE ID $CanChangeFeatCat = $user->authorise('flexicontent.change.cat.feat', 'com_flexicontent.type.' . $current_type_id); $CanChangeSecCat = $user->authorise('flexicontent.change.cat.sec', 'com_flexicontent.type.' . $current_type_id); $CanChangeCat = $user->authorise('flexicontent.change.cat', 'com_flexicontent.type.' . $current_type_id); $AutoApproveChanges = $perms->AutoApproveChanges; $enable_featured_cid_selector = $perms->MultiCat && $CanChangeFeatCat; $enable_cid_selector = $perms->MultiCat && $CanChangeSecCat; $enable_catid_selector = $isnew && !$params->get('catid_default') || !$isnew && !$model->get('catid') || $CanChangeCat; // Enforce maintaining featured categories $featured_cats_parent = $params->get('featured_cats_parent', 0); $featured_cats = array(); if ($featured_cats_parent && !$enable_featured_cid_selector) { $featured_tree = flexicontent_cats::getCategoriesTree($published_only = 1, $parent_id = $featured_cats_parent, $depth_limit = 0); $disabled_cats = $params->get('featured_cats_parent_disable', 1) ? array($featured_cats_parent) : array(); $featured_cid = array(); if (!$isnew) { foreach ($model->get('categories') as $item_cat) { if (isset($featured_tree[$item_cat]) && !isset($disabled_cats[$item_cat])) { $featured_cid[] = $item_cat; } } } $data['featured_cid'] = $featured_cid; } // Enforce maintaining secondary categories if (!$enable_cid_selector && (empty($data['submit_conf']) || empty($data['cid']))) { // respect submit menu cat override if ($isnew) { $data['cid'] = $params->get('cid_default'); } else { if (isset($featured_cid)) { $featured_cid_arr = array_flip($featured_cid); $sec_cid = array(); foreach ($model->get('cats') as $item_cat) { if (!isset($featured_cid_arr[$item_cat])) { $sec_cid[] = $item_cat; } } $data['cid'] = $sec_cid; } else { $data['cid'] = $model->get('cats'); } } } if (!$enable_catid_selector && (empty($data['submit_conf']) || empty($data['catid']))) { // respect submit menu cat override if ($isnew && $params->get('catid_default')) { $data['catid'] = $params->get('catid_default'); } else { if ($model->get('catid')) { $data['catid'] = $model->get('catid'); } } } // ************************** // Basic Form data validation // ************************** // Get the JForm object, but do not pass any data we only want the form object, // in order to validate the data and not create a filled-in form $form = $model->getForm(); // *** MANUALLY CHECK CAPTCHA *** $use_captcha = $params->get('use_captcha', 1); // 1 for guests, 2 for any user $captcha_formop = $params->get('captcha_formop', 0); // 0 for submit, 1 for submit/edit (aka always) $is_submitop = (int) $data['id'] == 0; $display_captcha = $use_captcha >= 2 || $use_captcha == 1 && $user->guest; $display_captcha = $display_captcha && ($is_submitop || $captcha_formop); // for submit operation we do not need to check 'captcha_formop' ... if ($display_captcha) { $c_plugin = $params->get('captcha', $app->getCfg('captcha')); // TODO add param to override default if ($c_plugin) { $c_name = 'captcha_response_field'; $c_value = JRequest::getString($c_name); $c_id = $c_plugin == 'recaptcha' ? 'dynamic_recaptcha_1' : 'fc_dynamic_captcha'; $c_namespace = 'fc_item_form'; $captcha_obj = JCaptcha::getInstance($c_plugin, array('namespace' => $c_namespace)); if (!$captcha_obj->checkAnswer($c_value)) { // Get the captch validation message and push it out to the user //$error = $captcha_obj->getError(); //$app->enqueueMessage($error instanceof Exception ? $error->getMessage() : $error, 'error'); $app->enqueueMessage(JText::_('FLEXI_CAPTCHA_FAILED') . ' ' . JText::_('FLEXI_MUST_REFILL_SOME_FIELDS'), 'error'); // Set POST form date into the session, so that they get reloaded $app->setUserState($form->option . '.edit.' . $form->context . '.data', $data); // Save the jform data in the session. $app->setUserState($form->option . '.edit.' . $form->context . '.custom', $custom); // Save the custom fields data in the session. $app->setUserState($form->option . '.edit.' . $form->context . '.jfdata', $jfdata); // Save the falang translations into the session $app->setUserState($form->option . '.edit.' . $form->context . '.unique_tmp_itemid', $unique_tmp_itemid); // Save temporary unique item id into the session // Redirect back to the item form $this->setRedirect($_SERVER['HTTP_REFERER']); if (JRequest::getVar('fc_doajax_submit')) { echo flexicontent_html::get_system_messages_html(); exit; // Ajax submit, do not rerender the view } return false; } } } // Validate Form data for core fields and for parameters $post = $model->validate($form, $data); // Check for validation error if (!$post) { // Get the validation messages and push up to three validation messages out to the user $errors = $form->getErrors(); for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) { $app->enqueueMessage($errors[$i] instanceof Exception ? $errors[$i]->getMessage() : $errors[$i], 'error'); } // Set POST form date into the session, so that they get reloaded $app->setUserState($form->option . '.edit.' . $form->context . '.data', $data); // Save the jform data in the session $app->setUserState($form->option . '.edit.' . $form->context . '.custom', $custom); // Save the custom fields data in the session $app->setUserState($form->option . '.edit.' . $form->context . '.jfdata', $jfdata); // Save the falang translations into the session $app->setUserState($form->option . '.edit.' . $form->context . '.unique_tmp_itemid', $unique_tmp_itemid); // Save temporary unique item id into the session // Redirect back to the item form $this->setRedirect($_SERVER['HTTP_REFERER']); if (JRequest::getVar('fc_doajax_submit')) { echo flexicontent_html::get_system_messages_html(); exit; // Ajax submit, do not rerender the view } return false; //die('error'); } // Some values need to be assigned after validation $post['attribs'] = @$data['attribs']; // Workaround for item's template parameters being clear by validation since they are not present in item.xml $post['custom'] =& $custom; // Assign array of custom field values, they are in the 'custom' form array instead of jform $post['jfdata'] =& $jfdata; // Assign array of Joomfish field values, they are in the 'jfdata' form array instead of jform // Assign template parameters of the select ilayout as an sub-array (the DB model will handle the merging of parameters) $ilayout = @$data['attribs']['ilayout']; // normal not be set if frontend template editing is not shown if ($ilayout && !empty($data['layouts'][$ilayout])) { $post['attribs']['layouts'] = $data['layouts']; } //echo "<pre>"; print_r($post['attribs']); exit; // USEFULL FOR DEBUGING for J2.5 (do not remove commented code) //$diff_arr = array_diff_assoc ( $data, $post); //echo "<pre>"; print_r($diff_arr); jexit(); // ******************************************************************************** // PERFORM ACCESS CHECKS, NOTE: we need to check access again, despite having // checked them on edit form load, because user may have tampered with the form ... // ******************************************************************************** $itemAccess = $model->getItemAccess(); $canAdd = $itemAccess->get('access-create'); // includes check of creating in at least one category $canEdit = $itemAccess->get('access-edit'); // includes privileges edit and edit-own $type_id = (int) @$post['type_id']; // Typecast to int, (already done for J2.5 via validating) if (!$isnew && $model->get('type_id') == $type_id) { // Existing item with Type not being ALTERED, content type can be maintained regardless of privilege $canCreateType = true; } else { // New item or existing item with Type is being ALTERED, check privilege to create items of this type $canCreateType = $model->canCreateType(array($type_id), true, $types); } // ***************************************************************** // Calculate user's CREATE / EDIT privileges on current content item // ***************************************************************** $hasCoupon = false; // Normally used in frontend only if (!$isnew) { // If no edit privilege, check if item is editable till logoff if (!$canEdit) { if ($session->has('rendered_uneditable', 'flexicontent')) { $rendered_uneditable = $session->get('rendered_uneditable', array(), 'flexicontent'); $canEdit = isset($rendered_uneditable[$model->get('id')]) && $rendered_uneditable[$model->get('id')]; $hasCoupon = isset($rendered_uneditable[$model->get('id')]) && $rendered_uneditable[$model->get('id')] == 2; // editable via coupon } } } else { // Allow creating via submit menu OVERRIDE if ($allowunauthorize) { $canAdd = true; $canCreateType = true; } } // New item: check if user can create in at least one category if ($isnew && !$canAdd) { JError::raiseWarning(403, JText::_('FLEXI_NO_ACCESS_CREATE')); $this->setRedirect($_SERVER['HTTP_REFERER']); if (JRequest::getVar('fc_doajax_submit')) { echo flexicontent_html::get_system_messages_html(); exit; // Ajax submit, do not rerender the view } return; } // Existing item: Check if user can edit current item if (!$isnew && !$canEdit) { JError::raiseWarning(403, JText::_('FLEXI_NO_ACCESS_EDIT')); $this->setRedirect($_SERVER['HTTP_REFERER']); if (JRequest::getVar('fc_doajax_submit')) { echo flexicontent_html::get_system_messages_html(); exit; // Ajax submit, do not rerender the view } return; } if (!$canCreateType) { $msg = isset($types[$type_id]) ? JText::sprintf('FLEXI_NO_ACCESS_CREATE_CONTENT_OF_TYPE', JText::_($types[$type_id]->name)) : ' Content Type ' . $type_id . ' was not found OR is not published'; JError::raiseWarning(403, $msg); $this->setRedirect($_SERVER['HTTP_REFERER']); if (JRequest::getVar('fc_doajax_submit')) { echo flexicontent_html::get_system_messages_html(); exit; // Ajax submit, do not rerender the view } return; } // Get "BEFORE SAVE" categories for information mail $before_cats = array(); if (!$isnew) { $query = 'SELECT DISTINCT c.id, c.title FROM #__categories AS c' . ' JOIN #__flexicontent_cats_item_relations AS rel ON rel.catid = c.id' . ' WHERE rel.itemid = ' . (int) $model->get('id'); $db->setQuery($query); $before_cats = $db->loadObjectList('id'); $before_maincat = $model->get('catid'); $original_item = $model->getItem($post['id'], $check_view_access = false, $no_cache = true, $force_version = 0); } // **************************************** // Try to store the form data into the item // **************************************** if (!$model->store($post)) { // Set error message about saving failed, and also the reason (=model's error message) $msg = JText::_('FLEXI_ERROR_STORING_ITEM'); JError::raiseWarning(500, $msg . ": " . $model->getError()); // Set POST form date into the session, so that they get reloaded $app->setUserState($form->option . '.edit.' . $form->context . '.data', $data); // Save the jform data in the session $app->setUserState($form->option . '.edit.' . $form->context . '.custom', $custom); // Save the custom fields data in the session $app->setUserState($form->option . '.edit.' . $form->context . '.jfdata', $jfdata); // Save the falang translations into the session $app->setUserState($form->option . '.edit.' . $form->context . '.unique_tmp_itemid', $unique_tmp_itemid); // Save temporary unique item id into the session // Saving has failed check-in and redirect back to the item form, // redirect back to the item form reloading the posted data $model->checkin(); $this->setRedirect($_SERVER['HTTP_REFERER']); if (JRequest::getVar('fc_doajax_submit')) { echo flexicontent_html::get_system_messages_html(); exit; // Ajax submit, do not rerender the view } return; //die('save error'); } // ************************************************** // Check in model and get item id in case of new item // ************************************************** $model->checkin(); $post['id'] = $isnew ? (int) $model->get('id') : $post['id']; // Get items marked as newly submitted $newly_submitted = $session->get('newly_submitted', array(), 'flexicontent'); if ($isnew) { // Mark item as newly submitted, to allow to a proper "THANKS" message after final save & close operation (since user may have clicked add instead of add & close) $newly_submitted[$model->get('id')] = 1; $session->set('newly_submitted', $newly_submitted, 'flexicontent'); } $newly_submitted_item = @$newly_submitted[$model->get('id')]; // *********************************************************************************************************** // Get newly saved -latest- version (store task gets latest) of the item, and also calculate publish privelege // *********************************************************************************************************** $item = $model->getItem($post['id'], $check_view_access = false, $no_cache = true, $force_version = -1); $canPublish = $model->canEditState($item, $check_cat_perm = true) || $hasCoupon; // ******************************************************************************************** // Use session to detect multiple item saves to avoid sending notification EMAIL multiple times // ******************************************************************************************** $is_first_save = true; if ($session->has('saved_fcitems', 'flexicontent')) { $saved_fcitems = $session->get('saved_fcitems', array(), 'flexicontent'); $is_first_save = $isnew ? true : !isset($saved_fcitems[$model->get('id')]); } // Add item to saved items of the corresponding session array $saved_fcitems[$model->get('id')] = $timestamp = time(); // Current time as seconds since Unix epoc; $session->set('saved_fcitems', $saved_fcitems, 'flexicontent'); // ******************************************** // Get categories added / removed from the item // ******************************************** $query = 'SELECT DISTINCT c.id, c.title FROM #__categories AS c' . ' JOIN #__flexicontent_cats_item_relations AS rel ON rel.catid = c.id' . ' WHERE rel.itemid = ' . (int) $model->get('id'); $db->setQuery($query); $after_cats = $db->loadObjectList('id'); if (!$isnew) { $cats_added_ids = array_diff(array_keys($after_cats), array_keys($before_cats)); foreach ($cats_added_ids as $cats_added_id) { $cats_added_titles[] = $after_cats[$cats_added_id]->title; } $cats_removed_ids = array_diff(array_keys($before_cats), array_keys($after_cats)); foreach ($cats_removed_ids as $cats_removed_id) { $cats_removed_titles[] = $before_cats[$cats_removed_id]->title; } $cats_altered = count($cats_added_ids) + count($cats_removed_ids); $after_maincat = $model->get('catid'); } // ******************************************************************************************************************* // We need to get emails to notify, from Global/item's Content Type parameters -AND- from item's categories parameters // ******************************************************************************************************************* $notify_emails = array(); if ($is_first_save || $cats_altered || $params->get('nf_enable_debug', 0)) { // Get needed flags regarding the saved items $approve_version = 2; $pending_approval_state = -3; $draft_state = -4; $current_version = FLEXIUtilities::getCurrentVersions($item->id, true); // Get current item version $last_version = FLEXIUtilities::getLastVersions($item->id, true); // Get last version (=latest one saved, highest version id), // $post variables vstate & state may have been (a) tampered in the form, and/or (b) altered by save procedure so better not use them $needs_version_reviewal = !$isnew && $last_version > $current_version && !$canPublish && !$AutoApproveChanges; $needs_publication_approval = $isnew && $item->state == $pending_approval_state && !$canPublish; $draft_from_non_publisher = $item->state == $draft_state && !$canPublish; if ($draft_from_non_publisher) { // Suppress notifications for draft-state items (new or existing ones), for these each author will publication approval manually via a button $nConf = false; } else { // Get notifications configuration and select appropriate emails for current saving case $nConf = $model->getNotificationsConf($params); //echo "<pre>"; print_r($nConf); "</pre>"; } if ($nConf) { $states_notify_new = $params->get('states_notify_new', array(1, 0, FLEXI_J16GE ? 2 : -1, -3, -4, -5)); if (empty($states_notify_new)) { $states_notify_new = array(); } else { if (!is_array($states_notify_new)) { $states_notify_new = !FLEXI_J16GE ? array($states_notify_new) : explode("|", $states_notify_new); } } $states_notify_existing = $params->get('states_notify_existing', array(1, 0, FLEXI_J16GE ? 2 : -1, -3, -4, -5)); if (empty($states_notify_existing)) { $states_notify_existing = array(); } else { if (!is_array($states_notify_existing)) { $states_notify_existing = !FLEXI_J16GE ? array($states_notify_existing) : explode("|", $states_notify_existing); } } $n_state_ok = in_array($item->state, $states_notify_new); $e_state_ok = in_array($item->state, $states_notify_existing); if ($needs_publication_approval) { $notify_emails = $nConf->emails->notify_new_pending; } else { if ($isnew && $n_state_ok) { $notify_emails = $nConf->emails->notify_new; } else { if ($isnew) { $notify_emails = array(); } else { if ($needs_version_reviewal) { $notify_emails = $nConf->emails->notify_existing_reviewal; } else { if (!$isnew && $e_state_ok) { $notify_emails = $nConf->emails->notify_existing; } else { if (!$isnew) { $notify_emails = array(); } } } } } } if ($needs_publication_approval) { $notify_text = $params->get('text_notify_new_pending'); } else { if ($isnew) { $notify_text = $params->get('text_notify_new'); } else { if ($needs_version_reviewal) { $notify_text = $params->get('text_notify_existing_reviewal'); } else { if (!$isnew) { $notify_text = $params->get('text_notify_existing'); } } } } //print_r($notify_emails); jexit(); } } // ********************************************************************************************************************* // If there are emails to notify for current saving case, then send the notifications emails, but // ********************************************************************************************************************* if (!empty($notify_emails) && count($notify_emails)) { $notify_vars = new stdClass(); $notify_vars->needs_version_reviewal = $needs_version_reviewal; $notify_vars->needs_publication_approval = $needs_publication_approval; $notify_vars->isnew = $isnew; $notify_vars->notify_emails = $notify_emails; $notify_vars->notify_text = $notify_text; $notify_vars->before_cats = $before_cats; $notify_vars->after_cats = $after_cats; $notify_vars->original_item = @$original_item; $model->sendNotificationEmails($notify_vars, $params, $manual_approval_request = 0); } // *************************************************** // CLEAN THE CACHE so that our changes appear realtime // *************************************************** $cache = FLEXIUtilities::getCache($group = '', 0); $cache->clean('com_flexicontent_items'); $cache->clean('com_flexicontent_filters'); $cache = FLEXIUtilities::getCache($group = '', 1); $cache->clean('com_flexicontent_items'); $cache->clean('com_flexicontent_filters'); // **************************************************************************************************************************** // Recalculate EDIT PRIVILEGE of new item. Reason for needing to do this is because we can have create permission in a category // and thus being able to set this category as item's main category, but then have no edit/editown permission for this category // **************************************************************************************************************************** $asset = 'com_content.article.' . $model->get('id'); $canEdit = $user->authorise('core.edit', $asset) || $user->authorise('core.edit.own', $asset) && $isOwner; // ALTERNATIVE 1 //$canEdit = $model->getItemAccess()->get('access-edit'); // includes privileges edit and edit-own // ALTERNATIVE 2 //$rights = FlexicontentHelperPerm::checkAllItemAccess($user->get('id'), 'item', $model->get('id')); //$canEdit = in_array('edit', $rights) || (in_array('edit.own', $rights) && $isOwner) ; // ******************************************************************************************************* // Check if user can not edit item further (due to changed main category, without edit/editown permission) // ******************************************************************************************************* if (!$canEdit) { if ($task == 'apply' || $task == 'apply_type') { // APPLY TASK: Temporarily set item to be editable till closing it and not through all session // (we will/should clear this flag when item is closed, since we have another flag to indicate new items $rendered_uneditable = $session->get('rendered_uneditable', array(), 'flexicontent'); $rendered_uneditable[$model->get('id')] = -1; $session->set('rendered_uneditable', $rendered_uneditable, 'flexicontent'); $canEdit = 1; } else { if ($newly_submitted_item) { // NEW ITEM: Do not use editable till logoff behaviour // ALSO: Clear editable FLAG set in the case that 'apply' button was used during new item creation if (!$params->get('items_session_editable', 0)) { $rendered_uneditable = $session->get('rendered_uneditable', array(), 'flexicontent'); if (isset($rendered_uneditable[$model->get('id')])) { unset($rendered_uneditable[$model->get('id')]); $session->set('rendered_uneditable', $rendered_uneditable, 'flexicontent'); } } } else { // EXISTING ITEM: (if enabled) Use the editable till logoff behaviour if ($params->get('items_session_editable', 0)) { // Set notice for existing item being editable till logoff JError::raiseNotice(403, JText::_('FLEXI_CANNOT_EDIT_AFTER_LOGOFF')); // Allow item to be editable till logoff $rendered_uneditable = $session->get('rendered_uneditable', array(), 'flexicontent'); $rendered_uneditable[$model->get('id')] = 1; $session->set('rendered_uneditable', $rendered_uneditable, 'flexicontent'); $canEdit = 1; } } } // Set notice about saving an item that cannot be changed further if (!$canEdit) { $app->enqueueMessage(JText::_('FLEXI_CANNOT_MAKE_FURTHER_CHANGES_TO_CONTENT'), 'message'); } } // **************************************************************** // Check for new Content Item is being closed, and clear some flags // **************************************************************** if ($task != 'apply' && $task != 'apply_type' && $newly_submitted_item) { // Clear item from being marked as newly submitted unset($newly_submitted[$model->get('id')]); $session->set('newly_submitted', $newly_submitted, 'flexicontent'); // The 'apply' task may set 'editable till logoff' FLAG ... // CLEAR IT, since NEW content this is meant to be used temporarily if (!$params->get('items_session_editable', 0)) { $rendered_uneditable = $session->get('rendered_uneditable', array(), 'flexicontent'); if (isset($rendered_uneditable[$model->get('id')])) { unset($rendered_uneditable[$model->get('id')]); $session->set('rendered_uneditable', $rendered_uneditable, 'flexicontent'); } } } // **************************************** // Saving is done, decide where to redirect // **************************************** // REDIRECT CASE FOR APPLYING: Save and reload the item edit form if ($task == 'apply' || $task == 'apply_type') { $msg = JText::_('FLEXI_ITEM_SAVED'); // Create the URL global $globalcats; $Itemid = JRequest::getInt('Itemid', 0); // maintain current menu item if this was given $item_url = JRoute::_(FlexicontentHelperRoute::getItemRoute($item->id . ':' . $item->alias, $globalcats[$item->catid]->slug, $Itemid)); $link = $item_url . (strstr($item_url, '?') ? '&' : '?') . 'task=edit'; // Important pass referer back to avoid making the form itself the referer // but also check that referer URL is 'safe' (allowed) , e.g. not an offsite URL, otherwise set referer to HOME page $referer = JRequest::getString('referer', JURI::base(), 'post'); if (!flexicontent_html::is_safe_url($referer)) { $referer = JURI::base(); } $return = '&return=' . base64_encode($referer); $link .= $return; } else { // REDIRECT CASE: Return to a custom page after creating a new item (e.g. a thanks page) if ($newly_submitted_item && $submit_redirect_url_fe) { $link = $submit_redirect_url_fe; $msg = JText::_('FLEXI_ITEM_SAVED'); } else { if ($task == 'save_a_preview') { $msg = JText::_('FLEXI_ITEM_SAVED'); $link = JRoute::_(FlexicontentHelperRoute::getItemRoute($model->_item->id . ':' . $model->_item->alias, $model->_item->catid, 0, $model->_item) . '&preview=1', false); } else { $msg = $newly_submitted_item ? JText::_('FLEXI_THANKS_SUBMISSION') : JText::_('FLEXI_ITEM_SAVED'); // Check that referer URL is 'safe' (allowed) , e.g. not an offsite URL, otherwise for returning to HOME page $link = JRequest::getString('referer', JURI::base(), 'post'); if (!flexicontent_html::is_safe_url($link)) { if ($dolog) { JFactory::getApplication()->enqueueMessage('refused redirection to possible unsafe URL: ' . $link, 'notice'); } $link = JURI::base(); } } } } $this->setRedirect($link, $msg); }
<div class="clear"></div> <?php } ?> <div id="ba-message" class="ba-message"></div> <textarea name="message" id="message" class="input-xlarge" placeholder="<?php echo $msg_text . "*"; ?> "></textarea> <div class="clear"></div> <?php if ($cheng_show_captcha != '0') { $ret = JPluginHelper::getPlugin('captcha'); if (!empty($ret)) { $name_captcha = $ret[0]->name; $captcha = JCaptcha::getInstance($name_captcha, array('namespace' => 'anything')); echo $captcha->display($name_captcha, $name_captcha); } } ?> <div id="ba_status"></div> <input id="ba_submit" name="button" class="ba-btn" type="submit" value="<?php echo $send_msg; ?> " onclick="javascript:send_mail();" /> <div class="clear"></div> </div> </div>
<span class="ui-button-text"><?php echo JText::_("LNG_CANCEL"); ?> </span> </button> </div> </div> <?php if ($this->appSettings->captcha && false) { ?> <div class="form-item"> <?php $namespace = "jbusinessdirectory.contact"; $class = " required"; $captcha = JCaptcha::getInstance("recaptcha", array('namespace' => $namespace)); if (!empty($captcha)) { $captcha->display("captcha", "captcha-div", $class); } ?> <div id="captcha-div"></div> </div> <?php } ?> </fieldset> </div> <?php echo JHTML::_('form.token'); ?>
// Toggler tab name $toggler_name = explode('|', $params->get('toggler_name', 'MOD_PWEBCONTACT_TOGGLER')); $params->def('toggler_name_open', str_replace('"', '', JText::_($toggler_name[0]))); $params->def('toggler_name_close', array_key_exists(1, $toggler_name) ? str_replace('"', '', JText::_($toggler_name[1])) : null); // Set media path $media_path = JPATH_ROOT . '/media/mod_pwebcontact/'; $params->set('media_path', $media_path); $media_url = JUri::base(true) . '/media/mod_pwebcontact/'; $params->set('media_url', $media_url); // Captcha $captcha_plugin = $params->get('captcha', 0); if ($captcha_plugin == -1) { $captcha_plugin = $app->getCfg('captcha', 0); $params->set('captcha', $captcha_plugin); } if ($captcha_plugin and ($captcha = JCaptcha::getInstance($captcha_plugin)) == null) { $params->set('captcha', 0); } // Set params modPwebcontactHelper::setParams($params); // Get JavaScript init code $script = modPwebcontactHelper::getScript(); // Load CSS and JS files and JS translations modPwebcontactHelper::initHeader(); // Module CSS classes modPwebcontactHelper::initCssClassess(); $positionClass = $params->get('positionClass'); $moduleClass = $params->get('moduleClass'); // Load fields $fields = modPwebcontactHelper::getFields(); require JModuleHelper::getLayoutPath('mod_pwebcontact', $params->get('layout', 'default'));
public static function ajax($bttask, $params) { $mainframe = JFactory::getApplication('site'); /** * check task is login to do */ if ($bttask == 'login') { JRequest::checkToken() or self::ajaxResponse('$error$' . JText::_('JINVALID_TOKEN')); if ($return = JRequest::getVar('return', '', 'method', 'base64')) { $return = base64_decode($return); if (!JURI::isInternal($return)) { $return = ''; } } $options = array(); $options['remember'] = JRequest::getBool('remember', false); $options['return'] = $return; $credentials = array(); $credentials['username'] = JRequest::getVar('username', '', 'method', 'username'); $credentials['password'] = JRequest::getString('passwd', '', 'post', JREQUEST_ALLOWRAW); //preform the login action $error = $mainframe->login($credentials, $options); self::ajaxResponse($error); } elseif ($bttask == 'register') { JRequest::checkToken() or self::ajaxResponse('$error$' . JText::_('JINVALID_TOKEN')); /** * check task is registration to do */ // If registration is disabled - Redirect to login page. if (JComponentHelper::getParams('com_users')->get('allowUserRegistration') == 0) { // set message in here : Registration is disable self::ajaxResponse("Registration is not allow!"); } //check captcha if ($params->get('use_captcha', 1)) { if ($params->get('use_captcha', 1) != 2) { $captcha = JFactory::getConfig()->get('captcha'); if ($captcha) { $reCaptcha = JCaptcha::getInstance($captcha); $checkCaptcha = $reCaptcha->checkAnswer(''); if ($checkCaptcha == false) { self::ajaxResponse('$error$' . JText::_('INCORRECT_CAPTCHA')); } } } else { $session = JFactory::getSession(); if (JRequest::getString('btl_captcha') != $session->get('btl_captcha')) { self::ajaxResponse('$error$' . JText::_('INCORRECT_CAPTCHA')); } } } // Get the user data. // reset params form name in getVar function (not yet) $jform = JRequest::getVar('jform'); $requestData['name'] = $jform['name']; $requestData['username'] = $jform['username']; $requestData['password1'] = $jform['password1']; $requestData['password2'] = $jform['password2']; $requestData['email1'] = $jform['email1']; $requestData['email2'] = $jform['email2']; //validate password $userConfig = JComponentHelper::getParams('com_users'); $minLength = $userConfig->get('minimum_length'); $minIntegers = $userConfig->get('minimum_integers'); $minSymbols = $userConfig->get('minimum_symbols'); $minUppercase = $userConfig->get('minimum_uppercase'); //check space if (strlen(str_replace(' ', '', $jform['password1'])) != strlen($jform['password1'])) { self::ajaxResponse('$error$' . JText::_('COM_USERS_MSG_SPACES_IN_PASSWORD')); } // Minimum length option if (strlen((string) $jform['password1']) < $minLength) { self::ajaxResponse('$error$' . JText::plural('COM_USERS_MSG_PASSWORD_TOO_SHORT_N', $minLength)); } //check integer $nInts = preg_match_all('/[0-9]/', $jform['password1'], $iMatches); if ($nInts < $minIntegers) { self::ajaxResponse('$error$' . JText::plural('COM_USERS_MSG_NOT_ENOUGH_INTEGERS_N', $minIntegers)); } $nUppercase = preg_match_all("/[A-Z]/", $jform['password1'], $uMatches); if ($nUppercase < $minUppercase) { self::ajaxResponse('$error$' . JText::plural('COM_USERS_MSG_NOT_ENOUGH_UPPERCASE_LETTERS_N', $minIntegers)); } $nsymbols = preg_match_all('[\\W]', $jform['password1'], $sMatches); if ($nsymbols < $minSymbols) { self::ajaxResponse('$error$' . JText::plural('COM_USERS_MSG_NOT_ENOUGH_SYMBOLS_N', $minSymbols)); } // Attempt to save the data. $return = self::register($requestData); if ($return === 'adminactivate') { self::ajaxResponse(JText::_('COM_USERS_REGISTRATION_COMPLETE_VERIFY')); } elseif ($return === 'useractivate') { self::ajaxResponse(JText::_('COM_USERS_REGISTRATION_COMPLETE_ACTIVATE')); } else { self::ajaxResponse(JText::_('COM_USERS_REGISTRATION_SAVE_SUCCESS')); } } else { self::ajaxResponse(self::createCaptcha()); } }
public function sendContactForm() { jimport('joomla.mail.helper'); $app = JFactory::getApplication(); // Get a JMail instance $mailer = JFactory::getMailer(); $params = $app->getParams(); $defaultFrom = $mailer->From; $defaultFromname = $mailer->FromName; $data = array('name' => JMailHelper::cleanLine($this->getState('contact.name')), 'email' => JMailHelper::cleanAddress($this->getState('contact.email')), 'telephone' => JMailHelper::cleanLine($this->getState('contact.telephone')), 'subject' => JMailHelper::cleanSubject($this->getState('contact.subject')) . ' [' . $defaultFromname . ']', 'message' => JMailHelper::cleanText($this->getState('contact.message')), 'propertyURL' => $this->getState('contact.propertyURL')); $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('jea'); if ($params->get('use_captcha')) { $plugin = JFactory::getConfig()->get('captcha'); if ($plugin == '0') { $plugin = 'recaptcha'; } $captcha = JCaptcha::getInstance($plugin); // Test the value. if (!$captcha->checkAnswer('')) { $error = $captcha->getError(); if ($error instanceof Exception) { $this->setError($error->getMessage()); } else { $this->setError($error); } } } // Check data if (empty($data['name'])) { $this->setError(JText::_('COM_JEA_YOU_MUST_TO_ENTER_YOUR_NAME')); } if (empty($data['message'])) { $this->setError(JText::_('COM_JEA_YOU_MUST_TO_ENTER_A_MESSAGE')); } if (!JMailHelper::isEmailAddress($data['email'])) { $this->setError(JText::sprintf('COM_JEA_INVALID_EMAIL_ADDRESS', $data['email'])); } if ($this->getErrors()) { return false; } $result = $dispatcher->trigger('onBeforeSendContactForm', array($data)); if (in_array(false, $result, true)) { return false; } $recipients = array(); $defaultMail = $params->get('default_mail'); $agentMail = ''; if ($params->get('send_form_to_agent') == 1) { $item = $this->getItem(); $db = $this->getDbo(); $q = 'SELECT `email` FROM `#__users` WHERE `id`=' . (int) $item->created_by; $db->setQuery($q); $agentMail = $db->loadResult(); } if (!empty($defaultMail) && !empty($agentMail)) { $recipients[] = $defaultMail; $recipients[] = $agentMail; } elseif (!empty($defaultMail)) { $recipients[] = $defaultMail; } elseif (!empty($agentMail)) { $recipients[] = $agentMail; } else { // Send to the webmaster email $recipients[] = $defaultFrom; } $body = $data['message'] . "\n"; if (!empty($data['telephone'])) { $body .= "\n" . JText::_('COM_JEA_TELEPHONE') . ' : ' . $data['telephone']; } $body .= "\n" . JText::_('COM_JEA_PROPERTY_URL') . ' : ' . $data['propertyURL']; $mailer->setBody($body); $ret = $mailer->sendMail($data['email'], $data['name'], $recipients, $data['subject'], $body, false); if ($ret == true) { $app->setUserState('contact.name', ''); $app->setUserState('contact.email', ''); $app->setUserState('contact.telephone', ''); $app->setUserState('contact.subject', ''); $app->setUserState('contact.message', ''); return true; } return false; }
/** * Method to get the field input. * * @return string The field input. * * @since 2.5 */ protected function getInput() { if ($this->hidden) { return ''; } else { if (($captcha = JCaptcha::getInstance($this->plugin, array('namespace' => $this->namespace))) == null) { return ''; } } return $captcha->display($this->name, $this->id, $this->class); }
/** * Process the subscription */ public function process_subscription() { JRequest::checkToken() or jexit('Invalid Token'); $config = OSMembershipHelper::getConfig(); if ($config->enable_captcha) { $input = JFactory::getApplication()->input; $captchaPlugin = JFactory::getApplication()->getParams()->get('captcha', JFactory::getConfig()->get('captcha')); $res = JCaptcha::getInstance($captchaPlugin)->checkAnswer($input->post->get('recaptcha_response_field', '', 'string')); if (!$res) { JError::raiseWarning('', JText::_('OSM_INVALID_CAPTCHA_ENTERED')); JRequest::setVar('view', 'register'); JRequest::setVar('layout', 'default'); JRequest::setVar('id', JRequest::getInt('plan_id')); $this->display(); return; } } $post = JRequest::get('post', JREQUEST_ALLOWHTML); $model = $this->getModel('Register'); $model->processSubscription($post); }
public static function checkCaptchaAjax() { self::initAjaxResponse(); if (($response = self::checkToken()) !== true) { return $response; } if (PWEBCONTACT_DEBUG) { self::$logs[] = 'Checking captcha'; } $app = JFactory::getApplication(); $params = self::getParams(); $response = array('status' => 101, 'msg' => ''); try { // Captcha $captcha_plugin = $params->get('captcha', $app->getCfg('captcha', 0)); if ($captcha_plugin and ($captcha = JCaptcha::getInstance($captcha_plugin)) != null) { if (!$captcha->checkAnswer($app->input->get('captcha', null, 'string'))) { if (PWEBCONTACT_DEBUG) { self::$logs[] = 'Invalid captcha code'; } $response = array('status' => 201, 'msg' => JText::_('MOD_PWEBCONTACT_INVALID_CAPTCHA_ERR')); } } } catch (Exception $e) { self::$logs[] = $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine(); $response = array('status' => 301, 'msg' => JText::_('MOD_PWEBCONTACT_JOOMLA_ERR')); } $response['debug'] = self::closeAjaxResponse(); return $response; }
public function save() { if (!JSession::checkToken()) { $this->setMessage('An error occurred. Please submit again.', 'error'); $this->redirect(); } $FUFUploadForm = $this->input->post->get('FUFUploadForm', array(), 'array'); $captcharesponse = JArrayHelper::getValue($FUFUploadForm, 'captcha', null, null); $captcha = JCaptcha::getInstance(JFactory::getConfig()->get('captcha')); if ($captcha && !$captcha->checkAnswer($captcharesponse)) { $vars = JFactory::getSession()->get('mathcaptcha'); $this->redirect(); } $toEmails = FUFParams::getEmails(); if (empty($toEmails)) { $this->setMessage('An error occurred.', 'error'); $this->redirect(); } $name = JArrayHelper::getValue($FUFUploadForm, 'name', '', 'string'); if (empty($name)) { $this->setMessage('Please enter a name', 'error'); $this->redirect(); } $email = JArrayHelper::getValue($FUFUploadForm, 'email', '', 'string'); if (!FUFValidate::email($email)) { $this->setMessage('Please enter a valid email', 'error'); $this->redirect(); } $phone = JArrayHelper::getValue($FUFUploadForm, 'phone', '', 'string'); if (empty($phone)) { $this->setMessage('Please enter a phone', 'error'); $this->redirect(); } $FUFFilesUpload = array_filter($this->input->post->get('FUFFilesUpload', array(), 'array')); JLoader::import('cms.html.number'); $mail = JFactory::getMailer(); $mail->IsHTML(); $mail->addReplyTo($email, $name); foreach ($toEmails as $toEmail) { $mail->addRecipient($toEmail); } $mail->setSubject(FUFParams::getSubject()); ob_start(); ?> <b>Company:</b> <?php echo htmlspecialchars(JArrayHelper::getValue($FUFUploadForm, 'company', '', 'string')); ?> <br /> <b>Name:</b></u> <?php echo htmlspecialchars($name); ?> <br /> <b>Email:</b></u> <?php echo htmlspecialchars($email); ?> <br /> <b>Phone:</b></u> <?php echo htmlspecialchars($phone); ?> <br /> <b>How they heard about CILE:</b></u> <?php echo htmlspecialchars(JArrayHelper::getValue($FUFUploadForm, 'how', '', 'string')); ?> <br /> <b>Desired Completion Date:</b></u> <?php echo htmlspecialchars(JArrayHelper::getValue($FUFUploadForm, 'completion', '', 'string')); ?> <br /> <u><b>Message:</b></u><br /><?php echo htmlspecialchars(JArrayHelper::getValue($FUFUploadForm, 'message', '', 'string')); ?> <br /> <?php if (!empty($FUFFilesUpload)) { ?> <u><b>Files:</b></u><br /> <?php foreach ($FUFFilesUpload as $key => $val) { $file = json_decode($val); ?> <a href="<?php echo htmlspecialchars($file->url); ?> " target="_blank"> <?php echo htmlspecialchars($file->name); ?> </a> - <?php echo htmlspecialchars(JHtmlNumber::bytes($file->size)); ?> <br /> <?php } ?> <?php } else { ?> <u><b>No Files Uploaded</b></u> <?php } ?> <?php $mail->setBody(ob_get_clean()); $mail->Send(); $this->setMessage('Thank you for your inquiry. A customer service representative will respond to your shortly.'); }
function sendEmail() { //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //Get data global $mainframe; $mail = JFactory::getMailer(); $modId = JRequest::getVar('modId'); $db = JFactory::getDBO(); $sql = "SELECT params FROM #__modules WHERE id={$modId}"; $db->setQuery($sql); $data = $db->loadResult(); $params = json_decode($data); $success = $params->success; $failed = $params->failed; $recipient = $params->email; $email = JRequest::getVar('email'); $name = JRequest::getVar('name'); //$subject = JRequest::getVar('subject'); $mes = JRequest::getVar('message'); $message = ""; //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //generates a message string if (isset($_POST['address'])) { $address = JRequest::getVar('address'); if ($address != "Address") { $message .= "Address: "; $message .= $address . "<br>"; } } if (isset($_POST['city'])) { $city = JRequest::getVar('city'); if ($city != "City") { $message .= "City: "; $message .= "" . $city . "<br>"; } } if (isset($_POST['state'])) { $state = JRequest::getVar('state'); if ($state != "State") { $message .= "State: "; $message .= "" . $state . "<br>"; } } if (isset($_POST['zip'])) { $zip = JRequest::getVar('zip'); if ($zip != "Zip / Postal code") { $message .= "Zip/ Postal code: "; $message .= "" . $zip . "<br>"; } } if (isset($_POST['homePhone'])) { $homePhone = JRequest::getVar('homePhone'); if ($homePhone != "Home Phone") { $message .= "Home Phone: "; $message .= "" . $homePhone . "<br>"; } } if (isset($_POST['mobilePhone'])) { $mobilePhone = JRequest::getVar('mobilePhone'); if ($mobilePhone != "Mobile Phone") { $message .= "Mobile Phone: "; $message .= "" . $mobilePhone . "<br>"; } } if (isset($_POST['company'])) { $company = JRequest::getVar('company'); if ($company != "Company") { $message .= "Company: "; $message .= "" . $company . "<br>"; } } if (isset($_POST['website'])) { $website = JRequest::getVar('website'); if ($website != "Website") { $message .= "Website: "; $message .= "" . $website . "<br>"; } } $message .= "" . $mes; //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! $cheng_show_captcha = JRequest::getVar('captcha'); if ($cheng_show_captcha != '0') { //captcha on $ret = JPluginHelper::getPlugin('captcha'); if (!empty($ret)) { $name_captcha = $ret[0]->name; $captcha = JCaptcha::getInstance($name_captcha, array('namespace' => 'anything')); $captcha->initialise($name_captcha); $answer = $captcha->checkAnswer($name_captcha); if (!$answer) { echo "<div class='error'>The reCAPTCHA wasn't entered correctly. Try it again!</div>"; exit; } } } $sender = array($email, $name); $mail->setSender($sender); $mail->addRecipient($recipient); if (isset($_POST['subject'])) { $subject = JRequest::getVar('subject'); if ($subject != "Subject") { $mail->setSubject($subject); } } else { $mail->setSubject(""); } $mail->isHTML(true); $mail->Encoding = 'base64'; $mail->setBody($message); if ($mail->Send()) { echo $success; } else { echo "<div class='error'>" . $failed . "</div>"; } }
</span> <br> <br> <!-- The global progress bar --> <div id="FUFFilesProgress" class="progress"> <div class="bar"></div> </div> <!-- The container for the uploaded files --> <div id="FUFFiles" class="files"></div> </div> </div> </div> </div> <div class="form-actions" style="margin-top: 0; padding-left: 0; text-align: center;"> <?php $captcha = JCaptcha::getInstance(JFactory::getConfig()->get('captcha')); if ($captcha) { echo $captcha->display('FUFUploadForm[captcha]', 'FUFCaptcha', 'input-mini required'); } ?> <br><br> <input type="submit" id="FUFSubmit" name="FUFSubmit" value="Submit" class="btn btn-large"> </div> <input type="hidden" name="task" value="uploadform.save" /> <input type="hidden" name="option" value="com_fileuploadform" /> <input type="hidden" name="view" value="<?php echo $this->escape($this->view); ?> " /> <input type="hidden" name="layout" value="<?php echo $this->escape($this->layout);
function requestQuoteCompanyAjax() { // Check for request forgeries. $appSettings = JBusinessUtil::getInstance()->getApplicationSettings(); $data = JRequest::get('post'); $errorFlag = false; $message = ""; if ($appSettings->captcha && false) { $namespace = "jbusinessdirectory.contact"; $captcha = JCaptcha::getInstance("recaptcha", array('namespace' => $namespace)); if (!$captcha->checkAnswer($post['recaptcha_response_field'])) { $error = $captcha->getError(); $this->setMessage("Captcha error!", 'warning'); $message = "Captcha error"; $errorFlag = true; return; } } $model = $this->getModel('companies'); $result = $model->requestQuoteCompany($data); if ($result) { $this->setMessage(JText::_('COM_JBUSINESS_DIRECTORY_COMPANY_CONTACTED')); } else { $this->setMessage(JText::_('COM_JBUSINESS_DIRECTORY_COMPANY_NOT_CONTACTED')); $message = "JText::_('COM_JBUSINESS_DIRECTORY_COMPANY_NOT_CONTACTED')"; $errorFlag = true; } echo '<?xml version="1.0" encoding="utf-8" ?>'; echo '<category_statement>'; echo '<answer error="' . (!$errorFlag ? "0" : "1") . '" errorMessage="' . $message . '"/>'; echo '</category_statement>'; echo '</xml>'; exit; }