/** * Get the redirect URL * * @param object $params Registry The module options. * @param string $type Type * @return string */ static function getReturnURL($params, $type) { $url = null; if ($itemid = $params->get($type)) { $db = App::get('db'); $query = $db->getQuery(true); $query->select($db->quoteName('link')); $query->from($db->quoteName('#__menu')); $query->where($db->quoteName('published') . '=1'); $query->where($db->quoteName('id') . '=' . $db->quote($itemid)); $db->setQuery($query); if ($link = $db->loadResult()) { $url = 'index.php?Itemid=' . $itemid; } } if (!$url) { // stay on the same page $uri = clone Uri::getInstance(); $vars = $uri->parse($uri->toString()); unset($vars['lang']); if (isset($vars['Itemid'])) { $itemid = $vars['Itemid']; $item = App::get('menu')->getItem($itemid); unset($vars['Itemid']); if (isset($item) && $vars == $item->query) { $url = 'index.php?Itemid=' . $itemid; } else { $url = 'index.php?' . $uri->buildQuery($vars) . '&Itemid=' . $itemid; } } else { $url = 'index.php?' . $uri->buildQuery($vars); } } return base64_encode($url); }
/** * Method to handle an error condition. * * @param Exception &$error The Exception object to be handled. * @return void */ public static function handleError(&$error) { include_once PATH_CORE . DS . 'components' . DS . 'com_redirect' . DS . 'models' . DS . 'link.php'; $renderer = new \Hubzero\Error\Renderer\Page(App::get('document'), App::get('template')->template, App::get('config')->get('debug')); // Make sure the error is a 404 and we are not in the administrator. if (!App::isAdmin() and $error->getCode() == 404) { // Render the error page. $renderer->render($error); } // Get the full current URI. $uri = \Hubzero\Utility\Uri::getInstance(); $current = $uri->toString(array('scheme', 'host', 'port', 'path', 'query', 'fragment')); // Attempt to ignore idiots. if (strpos($current, 'mosConfig_') !== false || strpos($current, '=http://') !== false) { // Render the error page. $renderer->render($error); } // See if the current url exists in the database as a redirect. $link = \Components\Redirect\Models\Link::all()->whereEquals('old_url', $current)->row(); // If no published redirect was found try with the server-relative URL if (!$link->id || $link->published != 1) { $currRel = $uri->toString(array('path', 'query', 'fragment')); $link = \Components\Redirect\Models\Link::all()->whereEquals('old_url', $currRel)->row(); } // If a redirect exists and is published, permanently redirect. if ($link->id && $link->published == 1) { App::redirect($link->new_url, null, null, true, false); } else { $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER']; $row = \Components\Redirect\Models\Link::all()->whereEquals('old_url', $current)->row(); if (!$row->get('id')) { $row->set(['old_url' => $current, 'new_url' => '', 'referer' => $referer, 'comment' => '', 'hits' => 1, 'published' => 0, 'created_date' => Date::toSql()]); } else { $row->set('hits', intval($row->get('hits')) + 1); } $row->save(); // Render the error page. $renderer->render($error); } }
/** * Display module content * * @return void */ public function display() { // Field labels $this->name_label = $this->params->get('name_label', Lang::txt('MOD_RAPID_CONTACT_FIELD_NAME')); $this->email_label = $this->params->get('email_label', Lang::txt('MOD_RAPID_CONTACT_FIELD_EMAIL')); $this->subject_label = $this->params->get('subject_label', Lang::txt('MOD_RAPID_CONTACT_FIELD_SUBJECT')); $this->message_label = $this->params->get('message_label', Lang::txt('MOD_RAPID_CONTACT_FIELD_MESSAGE')); // Button text $this->button_text = $this->params->get('button_text', Lang::txt('MOD_RAPID_CONTACT_SEND')); // Pre text $this->pre_text = $this->params->get('pre_text', ''); // Thank you message $this->page_text = $this->params->get('page_text', Lang::txt('MOD_RAPID_CONTACT_THANK_YOU')); // Error messages $this->error_text = $this->params->get('error_text', Lang::txt('MOD_RAPID_CONTACT_ERROR_SENDING')); $this->no_email = $this->params->get('no_email', Lang::txt('MOD_RAPID_CONTACT_ERROR_NO_EMAIL')); $this->invalid_email = $this->params->get('invalid_email', Lang::txt('MOD_RAPID_CONTACT_ERROR_INVALID_EMAIL')); // From $this->from_name = $this->params->get('from_name', Lang::txt('MOD_RAPID_CONTACT')); $this->from_email = $this->params->get('from_email', '*****@*****.**'); // To $this->recipient = $this->params->get('email_recipient', Config::get('mailfrom')); if (!trim($this->recipient)) { $this->recipient = Config::get('mailfrom'); } // Enable Anti-spam? $this->enable_anti_spam = $this->params->get('enable_anti_spam', true); $this->anti_spam_q = $this->params->get('anti_spam_q', Lang::txt('MOD_RAPID_CONTACT_ANTIPSAM')); $this->anti_spam_a = $this->params->get('anti_spam_a', '2'); $this->mod_class_suffix = $this->params->get('moduleclass_sfx', ''); $disable_https = $this->params->get('disable_https', false); $exact_url = $this->params->get('exact_url', true); if (!$exact_url) { $this->url = filter_var(\Hubzero\Utility\Uri::getInstance()->toString(), FILTER_SANITIZE_URL); } else { if (!$disable_https) { $this->url = !empty($_SERVER['HTTPS']) ? 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] : 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; } else { $this->url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; } } //$qs = str_replace(array('"', '?'), '', urldecode($_SERVER['QUERY_STRING'])); //$aqs = explode('?', $this->url); //$this->url = $aqs[0] . '?' . urlencode($qs); $fixed_url = $this->params->get('fixed_url', true); if ($fixed_url) { $this->url = $this->params->get('fixed_url_address', ''); } $this->error = ''; $this->replacement = ''; $this->posted = array('name' => '', 'email' => '', 'subject' => '', 'message' => ''); if (isset($_POST['rp'])) { $this->posted = Request::getVar('rp', array(), 'post'); if ($this->enable_anti_spam) { if (!isset($this->posted['anti_spam_answer']) || $this->posted['anti_spam_answer'] != $this->anti_spam_a) { $this->error = Lang::txt('MOD_RAPID_CONTACT_INVALID_ANTIPSAM_ANSWER'); } } if ($this->posted['email'] === '') { $this->error = $this->no_email; } if (!preg_match("#^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,3})\$#i", $this->posted['email'])) { $this->error = $this->invalid_email; } if ($this->error == '') { $mySubject = Sanitize::clean($this->posted['subject']); $myMessage = Lang::txt('MOD_RAPID_CONTACT_MESSAGE_FROM', $this->posted['name'], $this->posted['email'], Request::getVar('HTTP_REFERER', '', 'SERVER'), Config::get('sitename')); $myMessage .= "\n\n" . Sanitize::clean($this->posted['message']); $this->from_email = $this->posted['email']; $this->from_name = isset($this->posted['name']) && Sanitize::clean($this->posted['name']) ? Sanitize::clean($this->posted['name']) : $this->posted['email']; $mailSender = new Message(); $mailSender->setSubject($mySubject)->addFrom($this->from_email, $this->from_name)->addTo($this->recipient)->addReplyTo($this->posted['email'], $this->posted['name'])->setBody($myMessage); if (!$mailSender->send()) { $this->error = $this->error_text; } else { $this->replacement = $this->page_text; } // Reset the message field $this->posted['subject'] = ''; $this->posted['message'] = ''; } } require $this->getLayoutPath($this->params->get('layout', 'default')); }
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * HUBzero is a registered trademark of Purdue University. * * @package hubzero-cms * @copyright Copyright 2005-2015 HUBzero Foundation, LLC. * @license http://opensource.org/licenses/MIT MIT */ // no direct access defined('_HZEXEC_') or die; //$base = Request::getVar('REQUEST_URI', rtrim(Request::base(true), '/'), 'server'); $base = filter_var(\Hubzero\Utility\Uri::getInstance()->toString(), FILTER_SANITIZE_URL); if ($this->params->get('button', 0) == 1) { ?> <div id="content-header-extra"> <ul id="useroptions"> <li> <a href="<?php echo Route::url('index.php?option=com_feedback&task=success_story'); ?> " class="icon-add btn add"> <?php echo Lang::txt('MOD_QUOTES_ADD_YOUR_STORY'); ?> </a> </li> </ul>