public static function ping($se) { $se = strtolower($se); if (!isset(self::$ses[$se])) { return false; } $cfg = new AimySitemapConfigHelper(); $sm_url = JUri::root() . $cfg->get('xml_path', '/sitemap.xml'); $req_url = sprintf(self::$ses[$se], urlencode($sm_url)); $u = new AimySitemapUri($req_url); $resp = null; AimySitemapHttpClient::set_ua_name('AimySitemapNotifier/3.16.0'); $resp = AimySitemapHttpClient::get_url($u); if (is_array($resp) && isset($resp['head']) && $resp['head']['code'] == '200') { AimySitemapLogger::debug("Notifier: Sending ping to {$se}: OK"); return true; } AimySitemapLogger::debug("Notifier: Sending ping to {$se}: FAILED ({$req_url})"); return false; }
public function display($cachable = false, $urlparams = false) { $view = $this->input->get('view', $this->default_view); $layout = $this->input->get('layout', 'default'); $id = $this->input->getInt('id'); if ($view == 'urls' && $layout == 'edit' && !$this->checkEditId('com_aimysitemap.edit.urls', $id)) { $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=com_aimysitemap&view=urls', false)); return false; } if (!AimySitemapConfigHelper::get_once('default_priority', 0)) { JFactory::getApplication()->enqueueMessage(JText::sprintf('AIMY_SM_MSG_NOT_CONFIGURED', JRoute::_('index.php?option=com_config&' . 'view=component&' . 'component=com_aimysitemap')), 'warning'); } JFactory::getDocument()->addStylesheet('components/com_aimysitemap/helpers/backend.css?r=3.16.0'); parent::display(); return $this; }
public function display($tpl = null) { $this->items = $this->get('Items'); $this->state = $this->get('State'); $this->pagination = $this->get('Pagination'); if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $rights = AimySitemapRightsHelper::getRights(); $this->allow_config = $rights->get('core.admin'); $this->allow_edit = $rights->get('core.edit'); $this->allow_write = $rights->get('aimysitemap.write'); $this->ajax_edit = AimySitemapConfigHelper::get_once('ajax_edit', true); if ($this->ajax_edit && $this->allow_edit) { JFactory::getDocument()->addScript(JURI::root() . 'administrator/components/' . 'com_aimysitemap/helpers/urls-ajax-edit.js' . '?r=3.16.0'); } $this->add_toolbar(); parent::display($tpl); }
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; }
public function toggle_state_ajax() { JSession::checkToken() or jexit(JText::_('INVALID TOKEN')); $rights = AimySitemapRightsHelper::getRights(); if (!$rights->get('core.edit') || !AimySitemapConfigHelper::get_once('ajax_edit', true)) { jexit(JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN')); } header('Content-Type: application/json; charset=UTF-8'); $jinput = JFactory::getApplication()->input; $id = $jinput->get('id', null, 'uint'); if (!is_null($id) && $id !== 0) { if ($this->getModel()->toggle_state($id)) { echo json_encode(array('ok' => 1)); } } JFactory::getApplication()->close(); }
public static function get_once($key, $default = null) { $cfg = new AimySitemapConfigHelper(); return $cfg->get($key, $default); }
private function set_ping_cfg() { $cfg = new AimySitemapConfigHelper(); $this->ping_cfg = array('ses' => array('Google' => $cfg->get('notify_google'), 'Bing' => $cfg->get('notify_bing')), 'url' => JUri::root() . $cfg->get('xml_path')); }