public function display($tpl = null) { if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $app = JFactory::getApplication(); if ($app->isSSLConnection()) { $msg = new AimySitemapMessageHelper(); $msg->notice(JText::_('AIMY_SM_CRAWL_HINT_SSL_ONLY')); } if ($this->get_config($app, 'offline')) { $msg = new AimySitemapMessageHelper(); $msg->error(JText::_('AIMY_SM_ERR_SITE_OFFLINE')); $this->addToolbar(); return false; } if (defined('JDEBUG') && JDEBUG) { $msg = new AimySitemapMessageHelper(); $msg->notice(JText::sprintf('AIMY_SM_MSG_CRAWL_DEBUG_ENABLED', AimySitemapLogger::get_path())); } $rights = AimySitemapRightsHelper::getRights(); $this->allow_crawl = $rights->get('aimysitemap.crawl'); $this->allow_config = $rights->get('core.admin'); $this->addToolbar(); if ($this->allow_crawl) { JFactory::getDocument()->addScript(JUri::root() . 'administrator/components/' . 'com_aimysitemap/helpers/crawl.js' . '?r=3.16.0'); } else { $msg = new AimySitemapMessageHelper(); $msg->error(JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN')); } parent::display($tpl); }
private function read_robots_txt($path) { $msg = new AimySitemapMessageHelper(); if (JFile::exists($path)) { $this->robotstxt = @file_get_contents($path); if ($this->robotstxt === false) { $msg->error(JText::_('AIMY_SM_ROBOTSTXT_FAILED_TO_READ')); $this->robotstxt = ''; } } else { $msg->message(JText::_('AIMY_SM_ROBOTSTXT_DOES_NOT_EXIST')); $msg->message(JText::_('AIMY_SM_ROBOTSTXT_LOADING_DEFAULT')); $this->robotstxt = @file_get_contents(JPATH_COMPONENT . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'default-robots.txt'); if ($this->robotstxt === false) { $msg->error(JText::_('AIMY_SM_ROBOTSTXT_LOADING_DEFAULT_FAILED')); $this->robotstxt = ''; } } }
public function save() { JSession::checkToken() or jexit(JText::_('INVALID TOKEN')); $rights = AimySitemapRightsHelper::getRights(); if (!$rights->get('aimysitemap.write')) { jexit(JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN')); } require_once JPATH_COMPONENT . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'message.php'; $msg = new AimySitemapMessageHelper(); $app = JFactory::getApplication(); $txt = $app->input->getString('robotstxt', ''); $path = JPATH_ROOT . DIRECTORY_SEPARATOR . 'robots.txt'; if (JFile::write($path, $txt) === false) { $msg->error(JText::_('AIMY_SM_ROBOTSTXT_FAILED_TO_WRITE')); } else { $msg->message(JText::_('AIMY_SM_ROBOTSTXT_WRITTEN')); } $this->setRedirect(JRoute::_('index.php?option=com_aimysitemap&view=robotstxt', false)); }
public function display($tpl = null) { if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $rights = AimySitemapRightsHelper::getRights(); $this->allow_notify = $rights->get('aimysitemap.notify'); $this->allow_config = $rights->get('core.admin'); if ($this->allow_notify) { JFactory::getDocument()->addScript(JUri::root() . 'administrator/components/' . 'com_aimysitemap/helpers/ping.js' . '?r=3.16.0'); $this->set_ping_cfg(); } else { require_once JPATH_COMPONENT . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'message.php'; $msg = new AimySitemapMessageHelper(); $msg->error(JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN')); } $this->addToolbar(); parent::display($tpl); }
private function _set_bool_by_input_and_redirect($field, $state, $msg_on, $msg_off) { JSession::checkToken() or jexit(JText::_('INVALID TOKEN')); $rights = AimySitemapRightsHelper::getRights(); if (!$rights->get('core.edit')) { $this->setError(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED')); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=com_aimysitemap&view=urls', false)); return false; } require_once JPATH_COMPONENT . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'message.php'; $msg = new AimySitemapMessageHelper(); $jin = JFactory::getApplication()->input; $ids = $jin->get('cid', array(), 'ARRAY'); JArrayHelper::toInteger($ids); $model = $this->getModel('Url', 'AimySitemapModel'); $method = "set_{$field}"; if (!method_exists($model, $method)) { $this->setError(JText::_('JERROR_AN_ERROR_HAS_OCCURRED')); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=com_aimysitemap&view=urls', false)); return false; } $n = 0; foreach ($ids as $id) { if ($id <= 0) { $msg->error(JText::_('JERROR_AN_ERROR_HAS_OCCURRED')); continue; } $model->{$method}($id, $state); $n++; } if ($n) { $msg->queue(sprintf($state == 1 ? $msg_on : $msg_off, count($ids))); } $this->setRedirect(JRoute::_('index.php?option=com_aimysitemap&view=urls', false)); return true; }
public static function unlink_file_if_exists() { require_once JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_aimysitemap' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'message.php'; $cfg = new AimySitemapConfigHelper(); $msg = new AimySitemapMessageHelper(); $rel_path = $cfg->get('xml_path'); if (empty($rel_path)) { return false; } $full_path = JPATH_ROOT . '/' . $rel_path; if (!JFile::exists($full_path)) { return false; } if (JFile::delete($full_path) === true) { $msg->message(JText::_('AIMY_SM_MSG_XML_FILE_REMOVED')); return true; } $msg->error(JText::_('AIMY_SM_MSG_XML_FILE_ERR_REMOVE')); return false; }