private function _sendEmail($data)
 {
     $app = JFactory::getApplication();
     // Sends the email to the admin
     $admin = JFactory::getUser(537);
     $recipient = $admin->email;
     // Sets the sender info from Global Configuration
     $config = JFactory::getConfig();
     $sender = array($config->get('mailfrom'), $config->get('fromname'));
     //Subject variables
     $sitename = $app->get('sitename');
     $subject = 'Feedback';
     //Form data
     $name = $data['name'];
     $email = JStringPunycode::emailToPunycode($data['email']);
     $addfeature = $data['add_feature'];
     $easytouse = $data['easy_to_use'];
     $otherfeedback = $data['other_feedback'];
     // Email body
     $body = 'From: ' . $name . ' <' . $email . '>' . "\r\n\r\nFeature they would like added to the site:\r\n" . stripslashes($addfeature) . "\r\n\r\nHow easy is the site to use? " . $easytouse . "\r\n\r\nOther feedback:\r\n" . $otherfeedback;
     //Joomla Mailer
     $mail = JFactory::getMailer();
     $mail->addRecipient($recipient);
     $mail->addReplyTo($email, $name);
     $mail->setSender($sender);
     $mail->setSubject($sitename . ' ' . $subject);
     $mail->setBody($body);
     $sent = $mail->Send();
     return $sent;
 }
Exemple #2
0
 /**
  * Method to get the field input markup.
  *
  * @return  string  The field input markup.
  *
  * @since   3.1.2 (CMS)
  */
 protected function getInput()
 {
     // Translate placeholder text
     $hint = $this->translateHint ? JText::_($this->hint) : $this->hint;
     // Initialize some field attributes.
     $size = !empty($this->size) ? ' size="' . $this->size . '"' : '';
     $maxLength = !empty($this->maxLength) ? ' maxlength="' . $this->maxLength . '"' : '';
     $class = !empty($this->class) ? ' class="' . $this->class . '"' : '';
     $readonly = $this->readonly ? ' readonly' : '';
     $disabled = $this->disabled ? ' disabled' : '';
     $required = $this->required ? ' required aria-required="true"' : '';
     $hint = $hint ? ' placeholder="' . $hint . '"' : '';
     $autocomplete = !$this->autocomplete ? ' autocomplete="off"' : ' autocomplete="' . $this->autocomplete . '"';
     $autocomplete = $autocomplete == ' autocomplete="on"' ? '' : $autocomplete;
     $autofocus = $this->autofocus ? ' autofocus' : '';
     $spellcheck = $this->spellcheck ? '' : ' spellcheck="false"';
     // Initialize JavaScript field attributes.
     $onchange = !empty($this->onchange) ? ' onchange="' . $this->onchange . '"' : '';
     // Including fallback code for HTML5 non supported browsers.
     JHtml::_('jquery.framework');
     JHtml::_('script', 'system/html5fallback.js', false, true);
     // Uris should never include <>" see see http://www.ietf.org/rfc/rfc1738.txt.
     $this->value = str_replace(array('<', '>', '"'), '', $this->value);
     return '<input type="url" name="' . $this->name . '"' . $class . ' id="' . $this->id . '" value="' . JStringPunycode::urlToUTF8($this->value, ENT_COMPAT, 'UTF-8') . '"' . $size . $disabled . $readonly . $hint . $autocomplete . $autofocus . $spellcheck . $onchange . $maxLength . $required . ' />';
 }
Exemple #3
0
 /**
  * @since  1.5
  */
 function &getData()
 {
     $user = JFactory::getUser();
     $app = JFactory::getApplication();
     $data = new stdClass();
     $input = $app->input;
     $method = $input->getMethod();
     $data->link = urldecode($input->{$method}->get('link', '', 'BASE64'));
     if ($data->link == '') {
         JError::raiseError(403, JText::_('COM_MAILTO_LINK_IS_MISSING'));
         $false = false;
         return $false;
     }
     // Load with previous data, if it exists
     $mailto = $app->input->post->getString('mailto', '');
     $sender = $app->input->post->getString('sender', '');
     $from = $app->input->post->getString('from', '');
     $subject = $app->input->post->getString('subject', '');
     if ($user->get('id') > 0) {
         $data->sender = $user->get('name');
         $data->from = $user->get('email');
     } else {
         $data->sender = $sender;
         $data->from = JStringPunycode::emailToPunycode($from);
     }
     $data->subject = $subject;
     $data->mailto = JStringPunycode::emailToPunycode($mailto);
     return $data;
 }
Exemple #4
0
 /**
  * Method to get the field input markup.
  *
  * @return  string  The field input markup.
  *
  * @since   3.1.2 (CMS)
  */
 protected function getInput()
 {
     // Translate placeholder text
     $hint = $this->translateHint ? JText::_($this->hint) : $this->hint;
     // Initialize some field attributes.
     $size = !empty($this->size) ? ' size="' . $this->size . '"' : '';
     $maxLength = !empty($this->maxLength) ? ' maxlength="' . $this->maxLength . '"' : '';
     $class = !empty($this->class) ? ' class="' . $this->class . '"' : '';
     $readonly = $this->readonly ? ' readonly' : '';
     $disabled = $this->disabled ? ' disabled' : '';
     $required = $this->required ? ' required aria-required="true"' : '';
     $hint = strlen($hint) ? ' placeholder="' . $hint . '"' : '';
     $autocomplete = !$this->autocomplete ? ' autocomplete="off"' : ' autocomplete="' . $this->autocomplete . '"';
     $autocomplete = $autocomplete == ' autocomplete="on"' ? '' : $autocomplete;
     $autofocus = $this->autofocus ? ' autofocus' : '';
     $spellcheck = $this->spellcheck ? '' : ' spellcheck="false"';
     // Note that the input type "url" is suitable only for external URLs, so if internal URLs are allowed
     // we have to use the input type "text" instead.
     $inputType = $this->element['relative'] ? 'type="text"' : 'type="url"';
     // Initialize JavaScript field attributes.
     $onchange = !empty($this->onchange) ? ' onchange="' . $this->onchange . '"' : '';
     // Including fallback code for HTML5 non supported browsers.
     JHtml::_('jquery.framework');
     JHtml::_('script', 'system/html5fallback.js', false, true);
     return '<input ' . $inputType . ' name="' . $this->name . '"' . $class . ' id="' . $this->id . '" value="' . htmlspecialchars(JStringPunycode::urlToUTF8($this->value), ENT_COMPAT, 'UTF-8') . '"' . $size . $disabled . $readonly . $hint . $autocomplete . $autofocus . $spellcheck . $onchange . $maxLength . $required . ' />';
 }
Exemple #5
0
 /**
  * Method to get the field input markup for e-mail addresses.
  *
  * @return  string  The field input markup.
  *
  * @since   11.1
  */
 protected function getInput()
 {
     // Translate placeholder text
     $hint = $this->translateHint ? JText::_($this->hint) : $this->hint;
     // Initialize some field attributes.
     $size = !empty($this->size) ? ' size="' . $this->size . '"' : '';
     $maxLength = !empty($this->maxLength) ? ' maxlength="' . $this->maxLength . '"' : '';
     $class = !empty($this->class) ? ' class="validate-email ' . $this->class . '"' : ' class="validate-email"';
     $readonly = $this->readonly ? ' readonly' : '';
     $disabled = $this->disabled ? ' disabled' : '';
     $required = $this->required ? ' required aria-required="true"' : '';
     $hint = $hint ? ' placeholder="' . $hint . '"' : '';
     $autocomplete = !$this->autocomplete ? ' autocomplete="off"' : ' autocomplete="' . $this->autocomplete . '"';
     $autocomplete = $autocomplete == ' autocomplete="on"' ? '' : $autocomplete;
     $autofocus = $this->autofocus ? ' autofocus' : '';
     $multiple = $this->multiple ? ' multiple' : '';
     $spellcheck = $this->spellcheck ? '' : ' spellcheck="false"';
     $tabindex = (int) $this->element['tabindex'] ? ' tabindex="' . (int) $this->element['tabindex'] . '"' : '';
     $title = strpos($this->class, 'hasTooltip') === false ? '' : ' title="' . (string) $this->title . '"';
     // Initialize JavaScript field attributes.
     $onchange = $this->onchange ? ' onchange="' . $this->onchange . '"' : '';
     // Including fallback code for HTML5 non supported browsers.
     JHtml::_('jquery.framework');
     JHtml::_('script', 'system/html5fallback.js', false, true);
     return '<input type="email" name="' . $this->name . '"' . $class . ' id="' . $this->id . '" value="' . htmlspecialchars(JStringPunycode::emailToUTF8($this->value, ENT_COMPAT, 'UTF-8')) . '"' . $spellcheck . $size . $disabled . $readonly . $onchange . $autocomplete . $multiple . $maxLength . $hint . $required . $autofocus . $tabindex . $title . ' />';
 }
Exemple #6
0
 /**
  * Method to test the email address and optionally check for uniqueness.
  *
  * @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   11.1
  */
 public function test(SimpleXMLElement $element, $value, $group = null, JRegistry $input = null, JForm $form = null)
 {
     // If the field is empty and not required, the field is valid.
     $required = (string) $element['required'] == 'true' || (string) $element['required'] == 'required';
     if (!$required && empty($value)) {
         return true;
     }
     // If the tld attribute is present, change the regular expression to require at least 2 characters for it.
     $tld = (string) $element['tld'] == 'tld' || (string) $element['tld'] == 'required';
     if ($tld) {
         $this->regex = '^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]{2,})$';
     }
     // Determine if the multiple attribute is present
     $multiple = (string) $element['multiple'] == 'true' || (string) $element['multiple'] == 'multiple';
     if ($multiple) {
         $values = explode(',', $value);
     }
     if (!$multiple) {
         // Handle idn e-mail addresses by converting to punycode.
         $value = JStringPunycode::emailToPunycode($value);
         // Test the value against the regular expression.
         if (!parent::test($element, $value, $group, $input, $form)) {
             return false;
         }
     } else {
         foreach ($values as $value) {
             // Handle idn e-mail addresses by converting to punycode.
             $value = JStringPunycode::emailToPunycode($value);
             // Test the value against the regular expression.
             if (!parent::test($element, $value, $group, $input, $form)) {
                 return false;
             }
         }
     }
     // Check if we should test for uniqueness. This only can be used if multiple is not true
     $unique = (string) $element['unique'] == 'true' || (string) $element['unique'] == 'unique';
     if ($unique && !$multiple) {
         // Get the database object and a new query object.
         $db = JFactory::getDbo();
         $query = $db->getQuery(true);
         // Build the query.
         $query->select('COUNT(*)')->from('#__users')->where('email = ' . $db->quote($value));
         // Get the extra field check attribute.
         $userId = $form instanceof JForm ? $form->getValue('id') : '';
         $query->where($db->quoteName('id') . ' <> ' . (int) $userId);
         // Set and query the database.
         $db->setQuery($query);
         $duplicate = (bool) $db->loadResult();
         if ($duplicate) {
             return false;
         }
     }
     return true;
 }
Exemple #7
0
 /**
  * Method to get the field input markup for e-mail addresses.
  *
  * @return  string  The field input markup.
  *
  * @since   11.1
  */
 protected function getInput()
 {
     // Initialize some field attributes.
     $size = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
     $maxLength = $this->element['maxlength'] ? ' maxlength="' . (int) $this->element['maxlength'] . '"' : '';
     $class = $this->element['class'] ? ' ' . (string) $this->element['class'] : '';
     $readonly = (string) $this->element['readonly'] == 'true' ? ' readonly="readonly"' : '';
     $disabled = (string) $this->element['disabled'] == 'true' ? ' disabled="disabled"' : '';
     $required = $this->required ? ' required="required" aria-required="true"' : '';
     // Initialize JavaScript field attributes.
     $onchange = $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
     return '<input type="text" name="' . $this->name . '" class="' . $class . '" id="' . $this->id . '" value="' . JStringPunycode::emailToUTF8($this->value, ENT_COMPAT, 'UTF-8') . '"' . $size . $disabled . $readonly . $onchange . $maxLength . $required . '/>';
 }
 /**
  * Simple JavaScript email cloaker
  *
  * By default replaces an email with a mailto link with email cloaked
  *
  * @param   string   $mail    The -mail address to cloak.
  * @param   boolean  $mailto  True if text and mailing address differ
  * @param   string   $text    Text for the link
  * @param   boolean  $email   True if text is an e-mail address
  *
  * @return  string  The cloaked email.
  *
  * @since   1.5
  */
 public static function cloak($mail, $mailto = true, $text = '', $email = true)
 {
     // Handle IDN addresses: punycode for href but utf-8 for text displayed.
     if ($mailto && (empty($text) || $email)) {
         // Use dedicated $text whereas $mail is used as href and must be punycoded.
         $text = JStringPunycode::emailToUTF8($text ? $text : $mail);
     } elseif (!$mailto) {
         // In that case we don't use link - so convert $mail back to utf-8.
         $mail = JStringPunycode::emailToUTF8($mail);
     }
     // Convert mail
     $mail = static::convertEncoding($mail);
     // Split email by @ symbol
     $mail = explode('@', $mail);
     $mail_parts = explode('.', $mail[1]);
     // Random number
     $rand = rand(1, 100000);
     $replacement = '<span id="cloak' . $rand . '">' . JText::_('JLIB_HTML_CLOAKING') . '</span>' . "<script type='text/javascript'>";
     $replacement .= "\n //<!--";
     $replacement .= "\n document.getElementById('cloak{$rand}').innerHTML = '';";
     $replacement .= "\n var prefix = '&#109;a' + 'i&#108;' + '&#116;o';";
     $replacement .= "\n var path = 'hr' + 'ef' + '=';";
     $replacement .= "\n var addy" . $rand . " = '" . @$mail[0] . "' + '&#64;';";
     $replacement .= "\n addy" . $rand . " = addy" . $rand . " + '" . implode("' + '&#46;' + '", $mail_parts) . "';";
     if ($mailto) {
         // Special handling when mail text is different from mail address
         if ($text) {
             // Convert text - here is the right place
             $text = static::convertEncoding($text);
             if ($email) {
                 // Split email by @ symbol
                 $text = explode('@', $text);
                 $text_parts = explode('.', $text[1]);
                 $replacement .= "\n var addy_text" . $rand . " = '" . @$text[0] . "' + '&#64;' + '" . implode("' + '&#46;' + '", @$text_parts) . "';";
             } else {
                 $replacement .= "\n var addy_text" . $rand . " = '" . $text . "';";
             }
             $replacement .= "\n document.getElementById('cloak{$rand}').innerHTML += '<a ' + path + '\\'' + prefix + ':' + addy" . $rand . " + '\\'>'+addy_text" . $rand . "+'<\\/a>';";
         } else {
             $replacement .= "\n document.getElementById('cloak{$rand}').innerHTML += '<a ' + path + '\\'' + prefix + ':' + addy" . $rand . " + '\\'>' +addy" . $rand . "+'<\\/a>';";
         }
     } else {
         $replacement .= "\n document.getElementById('cloak{$rand}').innerHTML += addy" . $rand . ";";
     }
     $replacement .= "\n //-->";
     $replacement .= "\n </script>";
     return $replacement;
 }
Exemple #9
0
 /**
  * Stores a contact
  *
  * @param   boolean  True to update fields even if they are null.
  *
  * @return  boolean  True on success, false on failure.
  *
  * @since   1.6
  */
 public function store($updateNulls = false)
 {
     // Transform the params field
     if (is_array($this->params)) {
         $registry = new JRegistry();
         $registry->loadArray($this->params);
         $this->params = (string) $registry;
     }
     $date = JFactory::getDate();
     $user = JFactory::getUser();
     if ($this->id) {
         // Existing item
         $this->modified = $date->toSql();
         $this->modified_by = $user->get('id');
     } else {
         // New contact. A contact created and created_by field can be set by the user,
         // so we don't touch either of these if they are set.
         if (!(int) $this->created) {
             $this->created = $date->toSql();
         }
         if (empty($this->created_by)) {
             $this->created_by = $user->get('id');
         }
     }
     // Set publish_up to null date if not set
     if (!$this->publish_up) {
         $this->publish_up = $this->_db->getNullDate();
     }
     // Set publish_down to null date if not set
     if (!$this->publish_down) {
         $this->publish_down = $this->_db->getNullDate();
     }
     // Set xreference to empty string if not set
     if (!$this->xreference) {
         $this->xreference = '';
     }
     // Store utf8 email as punycode
     $this->email_to = JStringPunycode::emailToPunycode($this->email_to);
     // Convert IDN urls to punycode
     $this->webpage = JStringPunycode::urlToPunycode($this->webpage);
     // Verify that the alias is unique
     $table = JTable::getInstance('Contact', 'ContactTable');
     if ($table->load(array('alias' => $this->alias, 'catid' => $this->catid)) && ($table->id != $this->id || $this->id == 0)) {
         $this->setError(JText::_('COM_CONTACT_ERROR_UNIQUE_ALIAS'));
         return false;
     }
     return parent::store($updateNulls);
 }
 /**
  * Method to save the form data.
  *
  * @param   array  $temp  The form data.
  *
  * @return  boolean  True on success, false on failure.
  *
  */
 public function comment($temp)
 {
     $data = (array) $this->getData();
     // Merge in the comment data.
     foreach ($temp as $k => $v) {
         $data[$k] = $v;
     }
     $data['state'] = 1;
     $data['content_id'] = (int) $data['content_id'];
     $data['visitor_email'] = JStringPunycode::emailToPunycode($data['visitor_email']);
     $data['visitor_comments'] = stripcslashes(nl2br(htmlentities($data['visitor_comments'])));
     $data['created'] = JFactory::getDate()->toSql();
     // Get a level row instance.
     $table = $this->getTable();
     if ($table->save($data) === false) {
         return false;
     }
     return true;
 }
Exemple #11
0
 /**
  * Overload the store method for the Weblinks table.
  *
  * @param   boolean	Toggle whether null values should be updated.
  *
  * @return  boolean  True on success, false on failure.
  *
  * @since   1.6
  */
 public function store($updateNulls = false)
 {
     $date = JFactory::getDate();
     $user = JFactory::getUser();
     $this->modified = $date->toSql();
     if ($this->id) {
         // Existing item
         $this->modified_by = $user->id;
     } else {
         // New weblink. A weblink created and created_by field can be set by the user,
         // so we don't touch either of these if they are set.
         if (!(int) $this->created) {
             $this->created = $date->toSql();
         }
         if (empty($this->created_by)) {
             $this->created_by = $user->id;
         }
     }
     // Set publish_up to null date if not set
     if (!$this->publish_up) {
         $this->publish_up = $this->getDbo()->getNullDate();
     }
     // Set publish_down to null date if not set
     if (!$this->publish_down) {
         $this->publish_down = $this->getDbo()->getNullDate();
     }
     // Verify that the alias is unique
     $table = JTable::getInstance('Weblink', 'WeblinksTable');
     if ($table->load(array('alias' => $this->alias, 'catid' => $this->catid)) && ($table->id != $this->id || $this->id == 0)) {
         $this->setError(JText::_('COM_WEBLINKS_ERROR_UNIQUE_ALIAS'));
         return false;
     }
     // Convert IDN urls to punycode
     $this->url = JStringPunycode::urlToPunycode($this->url);
     return parent::store($updateNulls);
 }
				<?php 
        if ($this->items[$i]->published == 0) {
            ?>
					<span class="label label-warning"><?php 
            echo JText::_('JUNPUBLISHED');
            ?>
</span>
				<?php 
        }
        ?>
				<br />
				<?php 
        if ($this->params->get('show_link')) {
            ?>
					<?php 
            $link = JStringPunycode::urlToUTF8($item->link);
            ?>
					<span class="list pull-left">
							<a href="<?php 
            echo $item->link;
            ?>
"><?php 
            echo $link;
            ?>
</a>
					</span>
					<br/>
				<?php 
        }
        ?>
				</li>
 /**
  * Method to save the form data.
  *
  * @param   array  The form data.
  *
  * @return  boolean  True on success.
  * @since    3.0
  */
 public function save($data)
 {
     $app = JFactory::getApplication();
     // Alter the title for save as copy
     if ($app->input->get('task') == 'save2copy') {
         list($name, $alias) = $this->generateNewTitle($data['catid'], $data['alias'], $data['name']);
         $data['name'] = $name;
         $data['alias'] = $alias;
         $data['published'] = 0;
     }
     $links = array('linka', 'linkb', 'linkc', 'linkd', 'linke');
     foreach ($links as $link) {
         if ($data['params'][$link]) {
             $data['params'][$link] = JStringPunycode::urlToPunycode($data['params'][$link]);
         }
     }
     if (parent::save($data)) {
         $assoc = JLanguageAssociations::isEnabled();
         if ($assoc) {
             $id = (int) $this->getState($this->getName() . '.id');
             $item = $this->getItem($id);
             // Adding self to the association
             $associations = $data['associations'];
             foreach ($associations as $tag => $id) {
                 if (empty($id)) {
                     unset($associations[$tag]);
                 }
             }
             // Detecting all item menus
             $all_language = $item->language == '*';
             if ($all_language && !empty($associations)) {
                 JError::raiseNotice(403, JText::_('COM_CONTACT_ERROR_ALL_LANGUAGE_ASSOCIATED'));
             }
             $associations[$item->language] = $item->id;
             // Deleting old association for these items
             $db = JFactory::getDbo();
             $query = $db->getQuery(true)->delete('#__associations')->where('context=' . $db->quote('com_contact.item'))->where('id IN (' . implode(',', $associations) . ')');
             $db->setQuery($query);
             $db->execute();
             if ($error = $db->getErrorMsg()) {
                 $this->setError($error);
                 return false;
             }
             if (!$all_language && count($associations)) {
                 // Adding new association for these items
                 $key = md5(json_encode($associations));
                 $query->clear()->insert('#__associations');
                 foreach ($associations as $id) {
                     $query->values($id . ',' . $db->quote('com_contact.item') . ',' . $db->quote($key));
                 }
                 $db->setQuery($query);
                 $db->execute();
                 if ($error = $db->getErrorMsg()) {
                     $this->setError($error);
                     return false;
                 }
             }
         }
         return true;
     }
     return false;
 }
Exemple #14
0
    $fields = $this->item->profile->getFieldset('profile');
    ?>
	<div class="contact-profile" id="users-profile-custom">
		<dl class="dl-horizontal">
			<?php 
    foreach ($fields as $profile) {
        if ($profile->value) {
            echo '<dt>' . $profile->label . '</dt>';
            $profile->text = htmlspecialchars($profile->value, ENT_COMPAT, 'UTF-8');
            switch ($profile->id) {
                case 'profile_website':
                    $v_http = substr($profile->value, 0, 4);
                    if ($v_http === 'http') {
                        echo '<dd><a href="' . $profile->text . '">' . JStringPunycode::urlToUTF8($profile->text) . '</a></dd>';
                    } else {
                        echo '<dd><a href="http://' . $profile->text . '">' . JStringPunycode::urlToUTF8($profile->text) . '</a></dd>';
                    }
                    break;
                case 'profile_dob':
                    echo '<dd>' . JHtml::_('date', $profile->text, JText::_('DATE_FORMAT_LC4'), false) . '</dd>';
                    break;
                default:
                    echo '<dd>' . $profile->text . '</dd>';
                    break;
            }
        }
    }
    ?>
		</dl>
	</div>
<?php 
Exemple #15
0
 /**
  * Function to punyencode utf8 mail when saving content
  *
  * @param   string  $text  The strings to encode
  *
  * @return  string  The punyencoded mail
  *
  * @since   3.5
  */
 public function emailToPunycode($text)
 {
     $pattern = '/(("mailto:)+[\\w\\.\\-\\+]+\\@[^"?]+\\.+[^."?]+("|\\?))/';
     if (preg_match_all($pattern, $text, $matches)) {
         foreach ($matches[0] as $match) {
             $match = (string) str_replace(array('?', '"'), '', $match);
             $text = (string) str_replace($match, JStringPunycode::emailToPunycode($match), $text);
         }
     }
     return $text;
 }
Exemple #16
0
 /**
  * Method to save the form data.
  *
  * @param   array  $data  The form data.
  *
  * @return  boolean  True on success.
  *
  * @since   1.6
  */
 public function save($data)
 {
     $input = JFactory::getApplication()->input;
     $filter = JFilterInput::getInstance();
     if (isset($data['metadata']) && isset($data['metadata']['author'])) {
         $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM');
     }
     if (isset($data['created_by_alias'])) {
         $data['created_by_alias'] = $filter->clean($data['created_by_alias'], 'TRIM');
     }
     if (isset($data['images']) && is_array($data['images'])) {
         $registry = new Registry();
         $registry->loadArray($data['images']);
         $data['images'] = (string) $registry;
     }
     if (isset($data['urls']) && is_array($data['urls'])) {
         $check = $input->post->get('jform', array(), 'array');
         foreach ($data['urls'] as $i => $url) {
             if ($url != false && ($i == 'urla' || $i == 'urlb' || $i == 'urlc')) {
                 if (preg_match('~^#[a-zA-Z]{1}[a-zA-Z0-9-_:.]*$~', $check['urls'][$i]) == 1) {
                     $data['urls'][$i] = $check['urls'][$i];
                 } else {
                     $data['urls'][$i] = JStringPunycode::urlToPunycode($url);
                 }
             }
         }
         unset($check);
         $registry = new Registry();
         $registry->loadArray($data['urls']);
         $data['urls'] = (string) $registry;
     }
     // Alter the title for save as copy
     if ($input->get('task') == 'save2copy') {
         $origTable = clone $this->getTable();
         $origTable->load($input->getInt('id'));
         if ($data['title'] == $origTable->title) {
             list($title, $alias) = $this->generateNewTitle($data['catid'], $data['alias'], $data['title']);
             $data['title'] = $title;
             $data['alias'] = $alias;
         } else {
             if ($data['alias'] == $origTable->alias) {
                 $data['alias'] = '';
             }
         }
         $data['state'] = 0;
     }
     // Automatic handling of alias for empty fields
     if (in_array($input->get('task'), array('apply', 'save', 'save2new')) && (!isset($data['id']) || (int) $data['id'] == 0)) {
         if ($data['alias'] == null) {
             if (JFactory::getConfig()->get('unicodeslugs') == 1) {
                 $data['alias'] = JFilterOutput::stringURLUnicodeSlug($data['title']);
             } else {
                 $data['alias'] = JFilterOutput::stringURLSafe($data['title']);
             }
             $table = JTable::getInstance('Content', 'JTable');
             if ($table->load(array('alias' => $data['alias'], 'catid' => $data['catid']))) {
                 $msg = JText::_('COM_CONTENT_SAVE_WARNING');
             }
             list($title, $alias) = $this->generateNewTitle($data['catid'], $data['alias'], $data['title']);
             $data['alias'] = $alias;
             if (isset($msg)) {
                 JFactory::getApplication()->enqueueMessage($msg, 'warning');
             }
         }
     }
     if (parent::save($data)) {
         if (isset($data['featured'])) {
             $this->featured($this->getState($this->getName() . '.id'), $data['featured']);
         }
         return true;
     }
     return false;
 }
 /**
  * Overload the store method for the Intervention table.
  *
  * @param   boolean	Toggle whether null values should be updated.
  * @return  boolean  True on success, false on failure.
  * @since   1.6
  */
 public function store($updateNulls = false)
 {
     $date = JFactory::getDate();
     $user = JFactory::getUser();
     if ($this->id) {
         // Existing item
         $this->modified = $date->toSql();
         $this->modified_by = $user->get('id');
     } else {
         // New intervention. A intervention created and created_by field can be set by the user,
         // so we don't touch either of these if they are set.
         if (!(int) $this->created) {
             $this->created = $date->toSql();
         }
         if (empty($this->created_by)) {
             $this->created_by = $user->get('id');
         }
     }
     if (isset($this->alias)) {
         // Verify that the alias is unique
         $table = JTable::getInstance('intervention', 'CostbenefitprojectionTable');
         if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) {
             $this->setError(JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION_ERROR_UNIQUE_ALIAS'));
             return false;
         }
     }
     if (isset($this->url)) {
         // Convert IDN urls to punycode
         $this->url = JStringPunycode::urlToPunycode($this->url);
     }
     if (isset($this->website)) {
         // Convert IDN urls to punycode
         $this->website = JStringPunycode::urlToPunycode($this->website);
     }
     return parent::store($updateNulls);
 }
Exemple #18
0
 /**
  * renderUrl
  *
  * @param   string  $url  Param.
  *
  * @return	string
  */
 public static function renderUrl($url)
 {
     if (EXTLY_J3) {
         return htmlspecialchars(JStringPunycode::urlToUTF8($url), ENT_COMPAT, 'UTF-8');
     } else {
         return htmlspecialchars($url, ENT_COMPAT, 'UTF-8');
     }
 }
 /**
  * Method to save the form data.
  *
  * @param   array  The form data.
  * @return  mixed  	The user id on success, false on failure.
  * @since   1.6
  */
 public function save($data)
 {
     $userId = !empty($data['id']) ? $data['id'] : (int) $this->getState('user.id');
     $user = new JUser($userId);
     // Prepare the data for the user object.
     $data['email'] = JStringPunycode::emailToPunycode($data['email1']);
     $data['password'] = $data['password1'];
     // Unset the username if it should not be overwritten
     $username = $data['username'];
     $isUsernameCompliant = $this->getState('user.username.compliant');
     if (!JComponentHelper::getParams('com_users')->get('change_login_name') && $isUsernameCompliant) {
         unset($data['username']);
     }
     // Unset the block so it does not get overwritten
     unset($data['block']);
     // Unset the sendEmail so it does not get overwritten
     unset($data['sendEmail']);
     // Bind the data.
     if (!$user->bind($data)) {
         $this->setError(JText::sprintf('COM_USERS_PROFILE_BIND_FAILED', $user->getError()));
         return false;
     }
     // Load the users plugin group.
     JPluginHelper::importPlugin('user');
     // Null the user groups so they don't get overwritten
     $user->groups = null;
     // Store the data.
     if (!$user->save()) {
         $this->setError($user->getError());
         return false;
     }
     return $user->id;
 }
Exemple #20
0
 /**
  * Method to save the form data.
  *
  * @param   array  The form data.
  *
  * @return  boolean  True on success.
  * @since   1.6
  */
 public function save($data)
 {
     $app = JFactory::getApplication();
     if (isset($data['images']) && is_array($data['images'])) {
         $registry = new JRegistry();
         $registry->loadArray($data['images']);
         $data['images'] = (string) $registry;
     }
     if (isset($data['urls']) && is_array($data['urls'])) {
         foreach ($data['urls'] as $i => $url) {
             if ($url != false && ($i == 'urla' || $i == 'urlb' || $i == 'urlc')) {
                 $data['urls'][$i] = JStringPunycode::urlToPunycode($url);
             }
         }
         $registry = new JRegistry();
         $registry->loadArray($data['urls']);
         $data['urls'] = (string) $registry;
     }
     // Alter the title for save as copy
     if ($app->input->get('task') == 'save2copy') {
         list($title, $alias) = $this->generateNewTitle($data['catid'], $data['alias'], $data['title']);
         $data['title'] = $title;
         $data['alias'] = $alias;
         $data['state'] = 0;
     }
     if (parent::save($data)) {
         if (isset($data['featured'])) {
             $this->featured($this->getState($this->getName() . '.id'), $data['featured']);
         }
         $assoc = JLanguageAssociations::isEnabled();
         if ($assoc) {
             $id = (int) $this->getState($this->getName() . '.id');
             $item = $this->getItem($id);
             // Adding self to the association
             $associations = $data['associations'];
             foreach ($associations as $tag => $id) {
                 if (empty($id)) {
                     unset($associations[$tag]);
                 }
             }
             // Detecting all item menus
             $all_language = $item->language == '*';
             if ($all_language && !empty($associations)) {
                 JError::raiseNotice(403, JText::_('COM_CONTENT_ERROR_ALL_LANGUAGE_ASSOCIATED'));
             }
             $associations[$item->language] = $item->id;
             // Deleting old association for these items
             $db = JFactory::getDbo();
             $query = $db->getQuery(true)->delete('#__associations')->where('context=' . $db->quote('com_content.item'))->where('id IN (' . implode(',', $associations) . ')');
             $db->setQuery($query);
             $db->execute();
             if ($error = $db->getErrorMsg()) {
                 $this->setError($error);
                 return false;
             }
             if (!$all_language && count($associations)) {
                 // Adding new association for these items
                 $key = md5(json_encode($associations));
                 $query->clear()->insert('#__associations');
                 foreach ($associations as $id) {
                     $query->values($id . ',' . $db->quote('com_content.item') . ',' . $db->quote($key));
                 }
                 $db->setQuery($query);
                 $db->execute();
                 if ($error = $db->getErrorMsg()) {
                     $this->setError($error);
                     return false;
                 }
             }
         }
         return true;
     }
     return false;
 }
Exemple #21
0
 /**
  * Method to save the form data.
  *
  * @param   array  $data  The form data.
  *
  * @return  boolean  True on success.
  *
  * @since   1.6
  */
 public function save($data)
 {
     $input = JFactory::getApplication()->input;
     $filter = JFilterInput::getInstance();
     if (isset($data['metadata']) && isset($data['metadata']['author'])) {
         $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM');
     }
     if (isset($data['created_by_alias'])) {
         $data['created_by_alias'] = $filter->clean($data['created_by_alias'], 'TRIM');
     }
     if (isset($data['images']) && is_array($data['images'])) {
         $registry = new Registry();
         $registry->loadArray($data['images']);
         $data['images'] = (string) $registry;
     }
     JLoader::register('CategoriesHelper', JPATH_ADMINISTRATOR . '/components/com_categories/helpers/categories.php');
     // Cast catid to integer for comparison
     $catid = (int) $data['catid'];
     // Check if New Category exists
     if ($catid > 0) {
         $catid = CategoriesHelper::validateCategoryId($data['catid'], 'com_content');
     }
     // Save New Categoryg
     if ($catid == 0 && $this->canCreateCategory()) {
         $table = array();
         $table['title'] = $data['catid'];
         $table['parent_id'] = 1;
         $table['extension'] = 'com_content';
         $table['language'] = $data['language'];
         $table['published'] = 1;
         // Create new category and get catid back
         $data['catid'] = CategoriesHelper::createCategory($table);
     }
     if (isset($data['urls']) && is_array($data['urls'])) {
         $check = $input->post->get('jform', array(), 'array');
         foreach ($data['urls'] as $i => $url) {
             if ($url != false && ($i == 'urla' || $i == 'urlb' || $i == 'urlc')) {
                 if (preg_match('~^#[a-zA-Z]{1}[a-zA-Z0-9-_:.]*$~', $check['urls'][$i]) == 1) {
                     $data['urls'][$i] = $check['urls'][$i];
                 } else {
                     $data['urls'][$i] = JStringPunycode::urlToPunycode($url);
                 }
             }
         }
         unset($check);
         $registry = new Registry();
         $registry->loadArray($data['urls']);
         $data['urls'] = (string) $registry;
     }
     // Alter the title for save as copy
     if ($input->get('task') == 'save2copy') {
         $origTable = clone $this->getTable();
         $origTable->load($input->getInt('id'));
         if ($data['title'] == $origTable->title) {
             list($title, $alias) = $this->generateNewTitle($data['catid'], $data['alias'], $data['title']);
             $data['title'] = $title;
             $data['alias'] = $alias;
         } else {
             if ($data['alias'] == $origTable->alias) {
                 $data['alias'] = '';
             }
         }
         $data['state'] = 0;
     }
     // Automatic handling of alias for empty fields
     if (in_array($input->get('task'), array('apply', 'save', 'save2new')) && (!isset($data['id']) || (int) $data['id'] == 0)) {
         if ($data['alias'] == null) {
             if (JFactory::getConfig()->get('unicodeslugs') == 1) {
                 $data['alias'] = JFilterOutput::stringURLUnicodeSlug($data['title']);
             } else {
                 $data['alias'] = JFilterOutput::stringURLSafe($data['title']);
             }
             $table = JTable::getInstance('Content', 'JTable');
             if ($table->load(array('alias' => $data['alias'], 'catid' => $data['catid']))) {
                 $msg = JText::_('COM_CONTENT_SAVE_WARNING');
             }
             list($title, $alias) = $this->generateNewTitle($data['catid'], $data['alias'], $data['title']);
             $data['alias'] = $alias;
             if (isset($msg)) {
                 JFactory::getApplication()->enqueueMessage($msg, 'warning');
             }
         }
     }
     if (parent::save($data)) {
         if (isset($data['featured'])) {
             $this->featured($this->getState($this->getName() . '.id'), $data['featured']);
         }
         return true;
     }
     return false;
 }
Exemple #22
0
 /**
  * Method to save the form data.
  *
  * @param   array  $data  The form data.
  *
  * @return  boolean  True on success.
  *
  * @since   1.6
  */
 public function save($data)
 {
     $input = JFactory::getApplication()->input;
     $filter = JFilterInput::getInstance();
     if (isset($data['metadata']) && isset($data['metadata']['author'])) {
         $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM');
     }
     if (isset($data['created_by_alias'])) {
         $data['created_by_alias'] = $filter->clean($data['created_by_alias'], 'TRIM');
     }
     if (isset($data['images']) && is_array($data['images'])) {
         $registry = new Registry();
         $registry->loadArray($data['images']);
         $data['images'] = (string) $registry;
     }
     if (isset($data['urls']) && is_array($data['urls'])) {
         foreach ($data['urls'] as $i => $url) {
             if ($url != false && ($i == 'urla' || $i == 'urlb' || $i == 'urlc')) {
                 $data['urls'][$i] = JStringPunycode::urlToPunycode($url);
             }
         }
         $registry = new Registry();
         $registry->loadArray($data['urls']);
         $data['urls'] = (string) $registry;
     }
     // Alter the title for save as copy
     if ($input->get('task') == 'save2copy') {
         $origTable = clone $this->getTable();
         $origTable->load($input->getInt('id'));
         if ($data['title'] == $origTable->title) {
             list($title, $alias) = $this->generateNewTitle($data['catid'], $data['alias'], $data['title']);
             $data['title'] = $title;
             $data['alias'] = $alias;
         } else {
             if ($data['alias'] == $origTable->alias) {
                 $data['alias'] = '';
             }
         }
         $data['state'] = 0;
     }
     // Automatic handling of alias for empty fields
     if (in_array($input->get('task'), array('apply', 'save', 'save2new')) && (!isset($data['id']) || (int) $data['id'] == 0)) {
         if ($data['alias'] == null) {
             if (JFactory::getConfig()->get('unicodeslugs') == 1) {
                 $data['alias'] = JFilterOutput::stringURLUnicodeSlug($data['title']);
             } else {
                 $data['alias'] = JFilterOutput::stringURLSafe($data['title']);
             }
             $table = JTable::getInstance('Content', 'JTable');
             if ($table->load(array('alias' => $data['alias'], 'catid' => $data['catid']))) {
                 $msg = JText::_('COM_CONTENT_SAVE_WARNING');
             }
             list($title, $alias) = $this->generateNewTitle($data['catid'], $data['alias'], $data['title']);
             $data['alias'] = $alias;
             if (isset($msg)) {
                 JFactory::getApplication()->enqueueMessage($msg, 'warning');
             }
         }
     }
     if (parent::save($data)) {
         if (isset($data['featured'])) {
             $this->featured($this->getState($this->getName() . '.id'), $data['featured']);
         }
         $assoc = JLanguageAssociations::isEnabled();
         if ($assoc) {
             $id = (int) $this->getState($this->getName() . '.id');
             $item = $this->getItem($id);
             // Adding self to the association
             $associations = $data['associations'];
             foreach ($associations as $tag => $id) {
                 if (empty($id)) {
                     unset($associations[$tag]);
                 }
             }
             // Detecting all item menus
             $all_language = $item->language == '*';
             if ($all_language && !empty($associations)) {
                 JError::raiseNotice(403, JText::_('COM_CONTENT_ERROR_ALL_LANGUAGE_ASSOCIATED'));
             }
             $associations[$item->language] = $item->id;
             // Deleting old association for these items
             $db = JFactory::getDbo();
             $query = $db->getQuery(true)->delete('#__associations')->where('context=' . $db->quote('com_content.item'))->where('id IN (' . implode(',', $associations) . ')');
             $db->setQuery($query);
             $db->execute();
             if ($error = $db->getErrorMsg()) {
                 $this->setError($error);
                 return false;
             }
             if (!$all_language && count($associations)) {
                 // Adding new association for these items
                 $key = md5(json_encode($associations));
                 $query->clear()->insert('#__associations');
                 foreach ($associations as $id) {
                     $query->values($id . ',' . $db->quote('com_content.item') . ',' . $db->quote($key));
                 }
                 $db->setQuery($query);
                 $db->execute();
                 if ($error = $db->getErrorMsg()) {
                     $this->setError($error);
                     return false;
                 }
             }
         }
         return true;
     }
     return false;
 }
Exemple #23
0
    /**
     * Method to start the password reset process.
     *
     * @param   array  $data  The data expected for the form.
     *
     * @return  mixed  Exception | JException | boolean
     *
     * @since   1.6
     */
    public function processResetRequest($data)
    {
        $config = JFactory::getConfig();
        // Get the form.
        $form = $this->getForm();
        $data['email'] = JStringPunycode::emailToPunycode($data['email']);
        // Check for an error.
        if ($form instanceof Exception) {
            return $form;
        }
        // Filter and validate the form data.
        $data = $form->filter($data);
        $return = $form->validate($data);
        // Check for an error.
        if ($return instanceof Exception) {
            return $return;
        }
        // Check the validation results.
        if ($return === false) {
            // Get the validation messages from the form.
            foreach ($form->getErrors() as $formError) {
                $this->setError($formError->getMessage());
            }
            return false;
        }
        // Find the user id for the given email address.
        $db = $this->getDbo();
        $query = $db->getQuery(true)->select('id')->from($db->quoteName('#__users'))->where($db->quoteName('email') . ' = ' . $db->quote($data['email']));
        // Get the user object.
        $db->setQuery($query);
        try {
            $userId = $db->loadResult();
        } catch (RuntimeException $e) {
            $this->setError(JText::sprintf('COM_USERS_DATABASE_ERROR', $e->getMessage()), 500);
            return false;
        }
        // Check for a user.
        if (empty($userId)) {
            $this->setError(JText::_('COM_USERS_INVALID_EMAIL'));
            return false;
        }
        // Get the user object.
        $user = JUser::getInstance($userId);
        // Make sure the user isn't blocked.
        if ($user->block) {
            $this->setError(JText::_('COM_USERS_USER_BLOCKED'));
            return false;
        }
        // Make sure the user isn't a Super Admin.
        if ($user->authorise('core.admin')) {
            $this->setError(JText::_('COM_USERS_REMIND_SUPERADMIN_ERROR'));
            return false;
        }
        // Make sure the user has not exceeded the reset limit
        if (!$this->checkResetLimit($user)) {
            $resetLimit = (int) JFactory::getApplication()->getParams()->get('reset_time');
            $this->setError(JText::plural('COM_USERS_REMIND_LIMIT_ERROR_N_HOURS', $resetLimit));
            return false;
        }
        // Set the confirmation token.
        $token = JApplicationHelper::getHash(JUserHelper::genRandomPassword());
        $salt = JUserHelper::getSalt('crypt-md5');
        $hashedToken = md5($token . $salt) . ':' . $salt;
        $user->activation = $hashedToken;
        // Save the user to the database.
        if (!$user->save(true)) {
            return new JException(JText::sprintf('COM_USERS_USER_SAVE_FAILED', $user->getError()), 500);
        }
        // Assemble the password reset confirmation link.
        $mode = $config->get('force_ssl', 0) == 2 ? 1 : -1;
        $itemid = UsersHelperRoute::getLoginRoute();
        $itemid = $itemid !== null ? '&Itemid=' . $itemid : '';
        $link = 'index.php?option=com_users&view=reset&layout=confirm&token=' . $token . $itemid;
        // Put together the email template data.
        $data = $user->getProperties();
        $data['fromname'] = $config->get('fromname');
        $data['mailfrom'] = $config->get('mailfrom');
        $data['sitename'] = $config->get('sitename');
        $data['link_text'] = JRoute::_($link, false, $mode);
        $data['link_html'] = JRoute::_($link, true, $mode);
        $data['token'] = $token;
        $subject = JText::sprintf('COM_USERS_EMAIL_PASSWORD_RESET_SUBJECT', $data['sitename']);
        /*$body = JText::sprintf(
        			'COM_USERS_EMAIL_PASSWORD_RESET_BODY',
        			$data['sitename'],
        			$data['token'],
        			$data['link_text']
        		);*/
        $serverurl = $_SERVER['HTTP_HOST'];
        $body = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width; maximum-scale=1.0;">
<title>RAS</title>

<style type="text/css">
 body{ margin:0px; padding:0px;}
@media only screen and (max-width:598px){
table[class="mainWd"]{ width:100% !important; }
.img{ width:100% !important; }
}
@media only screen and (max-width:599px){
table{ float:none !important; }
table[class="mainWd"]{ width:100% !important; }
table[class="table-width"]{ float:left !important}
.img{ width:100% !important; }
@media only screen and (max-width:480px){
td[class="wd660"]{ width:100% !important; float:left !important; text-align:center !important; }
.img1{ display:none !important}
td[class="wd360"]{ width:100% !important; float:left !important; text-align:center; margin-bottom:20px; }	
table[class="full_480"]{ width:220px !important;  text-align:center !important;  float:none !important;  }	
td[class="mob_hide"]{ display:none !important; }
}
 
.img {width:100% !important; }
.img {width:100% !important; }
</style>
</head>

<body style="background:#cccccc;-moz-text-size-adjust:none; -webkit-text-size-adjust:none; -ms-text-size-adjust:none;  ">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" >
<tr><td align="center">
	<table width="650" border="0" align="center" cellpadding="0" cellspacing="0" class="mainWd" >
    
<tr><td height="25" align="center" valign="middle" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#ffffff; background:#2a4c75">Can’t see this email? View it in your browser. </td></tr> 
    

  
  
  <tr>
    <td align="left" valign="top" class="bg" bgcolor="#ffffff">
	<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
    
<tr>    <td height="20" align="left" valign="top"> <img src="http://' . $serverurl . '/images/banner123.jpg" alt=" " class="img" border="0" align="left" style="display:block;width:100%"></td>    </tr>
 
    
     
     <tr><td height="20" align="center" valign="top"> </td></tr>
     
     <tr><td   align="center" valign="top">
       <table width="96%" border="0" align="center" cellpadding="0" cellspacing="0">
       <tr><td align="left" valign="top"><span style="font-family:Arial, Helvetica, sans-serif; font-size:14px; line-height:20px; color:#343434; font-weight:normal;">Dear <span style="color:#343434;text-transform:capitalize;">' . $data['name'] . ',</span><br /><br />We have received a request regarding the change of your password.</span>
<br /><br />

<span style="font-family:Arial, Helvetica, sans-serif; font-size:14px; line-height:20px; color:#343434; font-weight:normal;">The verification code is - </span> ' . $data['token'] . ' <br /> <br />
<span style="font-family:Arial, Helvetica, sans-serif; font-size:14px; line-height:20px; color:#343434; font-weight:normal;">Please ignore this mail if you don’t want to reset your password.</span></td></tr> 
<tr><td height="20" align="center" valign="top"> </td></tr>
<tr><td align="left" valign="top">
<span style="font-family:Arial, Helvetica, sans-serif; font-size:14px; line-height:20px; color:#343434; font-weight:normal;">Best regards,<br /> 
Team RAS</span>
 
 </td></tr>

 <tr><td height="20" align="center" valign="top"> </td></tr>
</table>
      </td>   
  </table>


</td>
 
   
	 
 
       <tr> <td align="center" valign="middle" height="37 " bgcolor="#2a4c75" > <span style="font-family:Arial, Helvetica, sans-serif; font-size:12px  ; color:#ffffff;-webkit-text-size-adjust: none;">Copyright © 2015. RAS All rights reserved </span></td>  
         </tr> 
     

  
  
  </table>
  </td>
  </tr>
<tr>
  <td align="center">&nbsp;</td>
</tr>
</table>

</body>
</html>';
        $mailer = JFactory::getMailer();
        $config = JFactory::getConfig();
        $subject = 'Forgot Password Request';
        $from = $config->get('mailfrom');
        $fromname = $config->get('fromname');
        $to = $user->email;
        $sender = array($from, $fromname);
        $mailer->isHTML(true);
        $mailer->setSender($sender);
        $mailer->addRecipient($to);
        $mailer->Encoding = 'base64';
        $mailer->setSubject($subject);
        $mailer->setBody($body);
        $return = $mailer->Send();
        // Check for an error.
        if ($return !== true) {
            return new JException(JText::_('COM_USERS_MAIL_FAILED'), 500);
        }
        return true;
    }
Exemple #24
0
 /**
  * Method to apply an input filter to a value based on field data.
  *
  * @param   string  $element  The XML element object representation of the form field.
  * @param   mixed   $value    The value to filter for the field.
  *
  * @return  mixed   The filtered value.
  *
  * @since   11.1
  */
 protected function filterField($element, $value)
 {
     // Make sure there is a valid SimpleXMLElement.
     if (!$element instanceof SimpleXMLElement) {
         return false;
     }
     // Get the field filter type.
     $filter = (string) $element['filter'];
     // Process the input value based on the filter.
     $return = null;
     switch (strtoupper($filter)) {
         // Access Control Rules.
         case 'RULES':
             $return = array();
             foreach ((array) $value as $action => $ids) {
                 // Build the rules array.
                 $return[$action] = array();
                 foreach ($ids as $id => $p) {
                     if ($p !== '') {
                         $return[$action][$id] = $p == '1' || $p == 'true' ? true : false;
                     }
                 }
             }
             break;
             // Do nothing, thus leaving the return value as null.
         // Do nothing, thus leaving the return value as null.
         case 'UNSET':
             break;
             // No Filter.
         // No Filter.
         case 'RAW':
             $return = $value;
             break;
             // Filter the input as an array of integers.
         // Filter the input as an array of integers.
         case 'INT_ARRAY':
             // Make sure the input is an array.
             if (is_object($value)) {
                 $value = get_object_vars($value);
             }
             $value = is_array($value) ? $value : array($value);
             JArrayHelper::toInteger($value);
             $return = $value;
             break;
             // Filter safe HTML.
         // Filter safe HTML.
         case 'SAFEHTML':
             $return = JFilterInput::getInstance(null, null, 1, 1)->clean($value, 'string');
             break;
             // Convert a date to UTC based on the server timezone offset.
         // Convert a date to UTC based on the server timezone offset.
         case 'SERVER_UTC':
             if ((int) $value > 0) {
                 // Get the server timezone setting.
                 $offset = JFactory::getConfig()->get('offset');
                 // Return an SQL formatted datetime string in UTC.
                 $return = JFactory::getDate($value, $offset)->toSql();
             } else {
                 $return = '';
             }
             break;
             // Convert a date to UTC based on the user timezone offset.
         // Convert a date to UTC based on the user timezone offset.
         case 'USER_UTC':
             if ((int) $value > 0) {
                 // Get the user timezone setting defaulting to the server timezone setting.
                 $offset = JFactory::getUser()->getParam('timezone', JFactory::getConfig()->get('offset'));
                 // Return a MySQL formatted datetime string in UTC.
                 $return = JFactory::getDate($value, $offset)->toSql();
             } else {
                 $return = '';
             }
             break;
             // Ensures a protocol is present in the saved field. Only use when
             // the only permitted protocols requre '://'. See JFormRuleUrl for list of these.
         // Ensures a protocol is present in the saved field. Only use when
         // the only permitted protocols requre '://'. See JFormRuleUrl for list of these.
         case 'URL':
             if (empty($value)) {
                 return false;
             }
             // This cleans some of the more dangerous characters but leaves special characters that are valid.
             $value = JFilterInput::getInstance()->clean($value, 'html');
             $value = trim($value);
             // <>" are never valid in a uri see http://www.ietf.org/rfc/rfc1738.txt.
             $value = str_replace(array('<', '>', '"'), '', $value);
             // Check for a protocol
             $protocol = parse_url($value, PHP_URL_SCHEME);
             // If there is no protocol and the relative option is not specified,
             // we assume that it is an external URL and prepend http://.
             if ($element['type'] == 'url' && !$protocol && !$element['relative'] || !$element['type'] == 'url' && !$protocol) {
                 $protocol = 'http';
                 // If it looks like an internal link, then add the root.
                 if (substr($value, 0) == 'index.php') {
                     $value = JUri::root() . $value;
                 }
                 // Otherwise we treat it is an external link.
                 // Put the url back together.
                 $value = $protocol . '://' . $value;
             } elseif (!$protocol && $element['relative']) {
                 $host = JUri::getInstance('SERVER')->gethost();
                 // If it starts with the host string, just prepend the protocol.
                 if (substr($value, 0) == $host) {
                     $value = 'http://' . $value;
                 } else {
                     $value = JUri::root() . $value;
                 }
             }
             $value = JStringPunycode::urlToPunycode($value);
             $return = $value;
             break;
         case 'TEL':
             $value = trim($value);
             // Does it match the NANP pattern?
             if (preg_match('/^(?:\\+?1[-. ]?)?\\(?([2-9][0-8][0-9])\\)?[-. ]?([2-9][0-9]{2})[-. ]?([0-9]{4})$/', $value) == 1) {
                 $number = (string) preg_replace('/[^\\d]/', '', $value);
                 if (substr($number, 0, 1) == 1) {
                     $number = substr($number, 1);
                 }
                 if (substr($number, 0, 2) == '+1') {
                     $number = substr($number, 2);
                 }
                 $result = '1.' . $number;
             } elseif (preg_match('/^\\+(?:[0-9] ?){6,14}[0-9]$/', $value) == 1) {
                 $countrycode = substr($value, 0, strpos($value, ' '));
                 $countrycode = (string) preg_replace('/[^\\d]/', '', $countrycode);
                 $number = strstr($value, ' ');
                 $number = (string) preg_replace('/[^\\d]/', '', $number);
                 $result = $countrycode . '.' . $number;
             } elseif (preg_match('/^\\+[0-9]{1,3}\\.[0-9]{4,14}(?:x.+)?$/', $value) == 1) {
                 if (strstr($value, 'x')) {
                     $xpos = strpos($value, 'x');
                     $value = substr($value, 0, $xpos);
                 }
                 $result = str_replace('+', '', $value);
             } elseif (preg_match('/[0-9]{1,3}\\.[0-9]{4,14}$/', $value) == 1) {
                 $result = $value;
             } else {
                 $value = (string) preg_replace('/[^\\d]/', '', $value);
                 if ($value != null && strlen($value) <= 15) {
                     $length = strlen($value);
                     // If it is fewer than 13 digits assume it is a local number
                     if ($length <= 12) {
                         $result = '.' . $value;
                     } else {
                         // If it has 13 or more digits let's make a country code.
                         $cclen = $length - 12;
                         $result = substr($value, 0, $cclen) . '.' . substr($value, $cclen);
                     }
                 } else {
                     $result = '';
                 }
             }
             $return = $result;
             break;
         default:
             // Check for a callback filter.
             if (strpos($filter, '::') !== false && is_callable(explode('::', $filter))) {
                 $return = call_user_func(explode('::', $filter), $value);
             } elseif (function_exists($filter)) {
                 $return = call_user_func($filter, $value);
             } else {
                 $return = JFilterInput::getInstance()->clean($value, $filter);
             }
             break;
     }
     return $return;
 }
Exemple #25
0
 /**
  * Method to get a model object, loading it if required.
  *
  * @param   array      $data                  The data to send in the email.
  * @param   stdClass   $contact               The user information to send the email to
  * @param   boolean    $copy_email_activated  True to send a copy of the email to the user.
  *
  * @return  boolean  True on success sending the email, false on failure.
  *
  * @since   1.6.4
  */
 private function _sendEmail($data, $contact, $copy_email_activated)
 {
     $app = JFactory::getApplication();
     if ($contact->email_to == '' && $contact->user_id != 0) {
         $contact_user = JUser::getInstance($contact->user_id);
         $contact->email_to = $contact_user->get('email');
     }
     $mailfrom = $app->get('mailfrom');
     $fromname = $app->get('fromname');
     $sitename = $app->get('sitename');
     $name = $data['contact_name'];
     $email = JStringPunycode::emailToPunycode($data['contact_email']);
     $subject = $data['contact_subject'];
     $body = $data['contact_message'];
     // Prepare email body
     $prefix = JText::sprintf('COM_CONTACT_ENQUIRY_TEXT', JUri::base());
     $body = $prefix . "\n" . $name . ' <' . $email . '>' . "\r\n\r\n" . stripslashes($body);
     $mail = JFactory::getMailer();
     $mail->addRecipient($contact->email_to);
     $mail->addReplyTo(array($email, $name));
     $mail->setSender(array($mailfrom, $fromname));
     $mail->setSubject($sitename . ': ' . $subject);
     $mail->setBody($body);
     $sent = $mail->Send();
     // If we are supposed to copy the sender, do so.
     // Check whether email copy function activated
     if ($copy_email_activated == true && !empty($data['contact_email_copy'])) {
         $copytext = JText::sprintf('COM_CONTACT_COPYTEXT_OF', $contact->name, $sitename);
         $copytext .= "\r\n\r\n" . $body;
         $copysubject = JText::sprintf('COM_CONTACT_COPYSUBJECT_OF', $subject);
         $mail = JFactory::getMailer();
         $mail->addRecipient($email);
         $mail->addReplyTo(array($email, $name));
         $mail->setSender(array($mailfrom, $fromname));
         $mail->setSubject($copysubject);
         $mail->setBody($copytext);
         $sent = $mail->Send();
     }
     return $sent;
 }
Exemple #26
0
 /**
  * Method to save the form data.
  *
  * @param   array  The form data.
  * @return  mixed  	The user id on success, false on failure.
  * @since   1.6
  */
 public function save($data)
 {
     $userId = !empty($data['id']) ? $data['id'] : (int) $this->getState('user.id');
     $user = new JUser($userId);
     // Prepare the data for the user object.
     $data['email'] = JStringPunycode::emailToPunycode($data['email1']);
     $data['password'] = $data['password1'];
     // Unset the username if it should not be overwritten
     $username = $data['username'];
     $isUsernameCompliant = $this->getState('user.username.compliant');
     if (!JComponentHelper::getParams('com_users')->get('change_login_name') && $isUsernameCompliant) {
         unset($data['username']);
     }
     // Unset the block so it does not get overwritten
     unset($data['block']);
     // Unset the sendEmail so it does not get overwritten
     unset($data['sendEmail']);
     // handle the two factor authentication setup
     if (array_key_exists('twofactor', $data)) {
         $model = new UsersModelUser();
         $twoFactorMethod = $data['twofactor']['method'];
         // Get the current One Time Password (two factor auth) configuration
         $otpConfig = $model->getOtpConfig($userId);
         if ($twoFactorMethod != 'none') {
             // Run the plugins
             FOFPlatform::getInstance()->importPlugin('twofactorauth');
             $otpConfigReplies = FOFPlatform::getInstance()->runPlugins('onUserTwofactorApplyConfiguration', array($twoFactorMethod));
             // Look for a valid reply
             foreach ($otpConfigReplies as $reply) {
                 if (!is_object($reply) || empty($reply->method) || $reply->method != $twoFactorMethod) {
                     continue;
                 }
                 $otpConfig->method = $reply->method;
                 $otpConfig->config = $reply->config;
                 break;
             }
             // Save OTP configuration.
             $model->setOtpConfig($userId, $otpConfig);
             // Generate one time emergency passwords if required (depleted or not set)
             if (empty($otpConfig->otep)) {
                 $oteps = $model->generateOteps($userId);
             }
         } else {
             $otpConfig->method = 'none';
             $otpConfig->config = array();
             $model->setOtpConfig($userId, $otpConfig);
         }
         // Unset the raw data
         unset($data['twofactor']);
         // Reload the user record with the updated OTP configuration
         $user->load($userId);
     }
     // Bind the data.
     if (!$user->bind($data)) {
         $this->setError(JText::sprintf('COM_USERS_PROFILE_BIND_FAILED', $user->getError()));
         return false;
     }
     // Load the users plugin group.
     JPluginHelper::importPlugin('user');
     // Null the user groups so they don't get overwritten
     $user->groups = null;
     // Store the data.
     if (!$user->save()) {
         $this->setError($user->getError());
         return false;
     }
     $user->tags = new JHelperTags();
     $user->tags->getTagIds($user->id, 'com_users.user');
     return $user->id;
 }
 /**
  * Validation and filtering
  *
  * @return  boolean  True if satisfactory
  *
  * @since   11.1
  */
 public function check()
 {
     // Set user id to null istead of 0, if needed
     if ($this->id === 0) {
         $this->id = null;
     }
     // Validate user information
     if (trim($this->name) == '') {
         $this->setError(JText::_('JLIB_DATABASE_ERROR_PLEASE_ENTER_YOUR_NAME'));
         return false;
     }
     if (trim($this->username) == '') {
         $this->setError(JText::_('JLIB_DATABASE_ERROR_PLEASE_ENTER_A_USER_NAME'));
         return false;
     }
     if (preg_match('#[<>"\'%;()&\\s\\\\]|\\.\\./#', $this->username) || strlen(utf8_decode($this->username)) < 2) {
         $this->setError(JText::sprintf('JLIB_DATABASE_ERROR_VALID_AZ09', 2));
         return false;
     }
     if (trim($this->email) == "" || !JMailHelper::isEmailAddress($this->email)) {
         $this->setError(JText::_('JLIB_DATABASE_ERROR_VALID_MAIL'));
         return false;
     }
     // Convert e-mail to punycode for storage
     $this->email = JStringPunycode::emailToPunycode($this->email);
     // Set the registration timestamp
     if (empty($this->registerDate) || $this->registerDate == $this->_db->getNullDate()) {
         $this->registerDate = JFactory::getDate()->toSql();
     }
     // Set the lastvisitDate timestamp
     if (empty($this->lastvisitDate)) {
         $this->lastvisitDate = $this->_db->getNullDate();
     }
     // Check for existing username
     $query = $this->_db->getQuery(true)->select($this->_db->quoteName('id'))->from($this->_db->quoteName('#__users'))->where($this->_db->quoteName('username') . ' = ' . $this->_db->quote($this->username))->where($this->_db->quoteName('id') . ' != ' . (int) $this->id);
     $this->_db->setQuery($query);
     $xid = (int) $this->_db->loadResult();
     if ($xid && $xid != (int) $this->id) {
         $this->setError(JText::_('JLIB_DATABASE_ERROR_USERNAME_INUSE'));
         return false;
     }
     // Check for existing email
     $query->clear()->select($this->_db->quoteName('id'))->from($this->_db->quoteName('#__users'))->where($this->_db->quoteName('email') . ' = ' . $this->_db->quote($this->email))->where($this->_db->quoteName('id') . ' != ' . (int) $this->id);
     $this->_db->setQuery($query);
     $xid = (int) $this->_db->loadResult();
     if ($xid && $xid != (int) $this->id) {
         $this->setError(JText::_('JLIB_DATABASE_ERROR_EMAIL_INUSE'));
         return false;
     }
     // Check for root_user != username
     $config = JFactory::getConfig();
     $rootUser = $config->get('root_user');
     if (!is_numeric($rootUser)) {
         $query->clear()->select($this->_db->quoteName('id'))->from($this->_db->quoteName('#__users'))->where($this->_db->quoteName('username') . ' = ' . $this->_db->quote($rootUser));
         $this->_db->setQuery($query);
         $xid = (int) $this->_db->loadResult();
         if ($rootUser == $this->username && (!$xid || $xid && $xid != (int) $this->id) || $xid && $xid == (int) $this->id && $rootUser != $this->username) {
             $this->setError(JText::_('JLIB_DATABASE_ERROR_USERNAME_CANNOT_CHANGE'));
             return false;
         }
     }
     return true;
 }
Exemple #28
0
 /**
  * Overriden JTable::store to set modified data.
  *
  * @param   boolean  $updateNulls  True to update fields even if they are null.
  *
  * @return  boolean  True on success.
  *
  * @since   1.6
  */
 public function store($updateNulls = false)
 {
     $date = JFactory::getDate();
     $user = JFactory::getUser();
     $this->modified = $date->toSql();
     if ($this->id) {
         // Existing item
         $this->modified_by = $user->get('id');
     } else {
         // New newsfeed. A feed created and created_by field can be set by the user,
         // so we don't touch either of these if they are set.
         if (!(int) $this->created) {
             $this->created = $date->toSql();
         }
         if (empty($this->created_by)) {
             $this->created_by = $user->get('id');
         }
     }
     // Verify that the alias is unique
     $table = JTable::getInstance('Newsfeed', 'NewsfeedsTable');
     if ($table->load(array('alias' => $this->alias, 'catid' => $this->catid)) && ($table->id != $this->id || $this->id == 0)) {
         $this->setError(JText::_('COM_NEWSFEEDS_ERROR_UNIQUE_ALIAS'));
         return false;
     }
     // Save links as punycode.
     $this->link = JStringPunycode::urlToPunycode($this->link);
     return parent::store($updateNulls);
 }
Exemple #29
0
 /**
  * Method to save the form data.
  *
  * @param   array  $data  The form data.
  *
  * @return  boolean  True on success, False on error.
  *
  */
 public function save($data)
 {
     // Include the knvbapi plugins for the onSave events.
     JPluginHelper::importPlugin('knvbapi2');
     $input = JFactory::getApplication()->input;
     $filter = JFilterInput::getInstance();
     if (isset($data['created_by_alias'])) {
         $data['created_by_alias'] = $filter->clean($data['created_by_alias'], 'TRIM');
     }
     if (isset($data['images']) and is_array($data['images'])) {
         $registry = new Registry();
         $registry->loadArray($data['images']);
         $data['images'] = (string) $registry;
         $registry = null;
         //release memory
     }
     if (isset($data['urls']) and is_array($data['urls'])) {
         foreach ($data['urls'] as $i => $url) {
             if ($url != false and ($i == 'urla' or $i == 'urlb' or $i == 'urlc')) {
                 $data['urls'][$i] = JStringPunycode::urlToPunycode($url);
             }
         }
         $registry = new Registry();
         $registry->loadArray($data['urls']);
         $data['urls'] = (string) $registry;
         $registry = null;
         //release memory
     }
     // Alter the name and alias for save as copy
     if ($input->get('task') == 'save2copy') {
         $data['name'] = $this->generateUniqueName($data);
         $data['alias'] = $this->generateUniqueAlias($data);
         $data['state'] = 0;
     }
     if (parent::save($data)) {
         if (isset($data['featured'])) {
             $this->featured($this->getState($this->getName() . '.id'), $data['featured']);
         }
         $assoc = JLanguageAssociations::isEnabled();
         if ($assoc) {
             $id = (int) $this->getState($this->getName() . '.id');
             $item = $this->getItem($id);
             // Adding self to the association
             $associations = $data['associations'];
             foreach ($associations as $tag => $id) {
                 if (empty($id)) {
                     unset($associations[$tag]);
                 }
             }
             // Detecting all item menus
             $all_language = $item->language == '*';
             if ($all_language and !empty($associations)) {
                 JError::raiseNotice(403, JText::_('COM_KNVBAPI2_ERROR_ALL_LANGUAGE_ASSOCIATED'));
             }
             $associations[$item->language] = $item->id;
             try {
                 // Deleting old association for these items
                 $db = JFactory::getDbo();
                 $query = $db->getQuery(true);
                 $query->delete($db->quoteName('#__associations'));
                 $query->where('context=' . $db->quote('com_knvbapi2.teamnaam.item'));
                 $query->where($db->quoteName('id') . ' IN (' . implode(',', $associations) . ')');
                 $db->setQuery($query);
                 $db->execute();
             } catch (RuntimeException $e) {
                 $this->setError($e->getMessage());
                 return false;
             }
             if (!$all_language and count($associations)) {
                 // Adding new association for these items
                 $key = md5(json_encode($associations));
                 $query->clear();
                 $query->insert($db->quoteName('#__associations'));
                 foreach ($associations as $id) {
                     $query->values($id . ',' . $db->quote('com_knvbapi2.teamnaam.item') . ',' . $db->quote($key));
                 }
                 try {
                     $db->setQuery($query);
                     $db->execute();
                 } catch (RuntimeException $e) {
                     $this->setError($e->getMessage());
                     return false;
                 }
             }
         }
         return true;
     }
     return false;
 }
        echo JText::_('COM_USERS_USERS_MULTIPLE_GROUPS');
        ?>
</span>
					<?php 
    } else {
        ?>
						<?php 
        echo nl2br($item->group_names);
        ?>
					<?php 
    }
    ?>
				</td>
				<td class="center">
					<?php 
    echo JStringPunycode::emailToUTF8($this->escape($item->email));
    ?>
				</td>
				<td class="center">
					<?php 
    if ($item->lastvisitDate != '0000-00-00 00:00:00') {
        ?>
						<?php 
        echo JHtml::_('date', $item->lastvisitDate, 'Y-m-d H:i:s');
        ?>
					<?php 
    } else {
        ?>
						<?php 
        echo JText::_('JNEVER');
        ?>