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 static function get_from_file() { if (JURI::root(true) !== '/') { return null; } $path = JPATH_ROOT . '/robots.txt'; if (JFile::exists($path)) { $txt = file_get_contents($path); if ($robots_txt !== false) { AimySitemapLogger::debug('Crawl-Init: Got robots.txt from filesystem'); } return $txt; } return null; }
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; }
private static function parse_head($s) { $a = explode("\r\n", trim($s)); $h = array_shift($a); $r = array(); preg_match('#^HTTP/1.\\d (\\d{3}) #', $h, $m); if (count($m) != 2) { AimySitemapLogger::debug("Crawl: HTTP HEAD response: [{$s}]"); AimySitemapLogger::debug("Crawl: parse_head failed: [{$h}]"); throw new RuntimeException('Failed to parse head: status code not found', self::MSG_PARSE_HTTP); } $r['code'] = $m[1]; while (!empty($a)) { $l = array_pop($a); $p = explode(':', $l, 2); if (count($p) != 2) { throw new RuntimeException('Failed to parse head: failed to split fields', self::MSG_PARSE_HTTP); } $r[$p[0]] = trim($p[1]); } return $r; }
public static function init() { jimport('joomla.log.log'); JLog::addLogger(array('text_file' => self::get_log_name(), 'text_file_path' => self::get_dir_path(), 'text_entry_format' => '{DATE} {TIME} {PRIORITY} {MESSAGE}'), JLog::ALL, 'aimysitemap'); self::$ready = true; }
return false; } else if ( task == 'crawl.abort' ) { g_aimysitemap_abort = true; jQuery( '#toolbar-unpublish button' ).prop( 'disabled', true ); jQuery( '#toolbar-tree-2 button' ).prop( 'disabled', false ); return false; } } <?php if (defined('JDEBUG') && JDEBUG && !is_readable(AimySitemapLogger::get_path())) { ?> jQuery( '#dl_btn_cnt' ).hide(); <?php } ?> }); </script> <?php } ?> <?php
public function get_log() { JSession::checkToken('get') or jexit(JText::_('INVALID TOKEN')); $rights = AimySitemapRightsHelper::getRights(); if (!$rights->get('aimysitemap.crawl')) { jexit(JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN')); } if (!defined('JDEBUG') or !JDEBUG) { jexit('This functionality is available in debugging mode only'); } $path = AimySitemapLogger::get_path(); if (!is_readable($path)) { throw new Exception('File not found', 404); } $fn = basename($path) . '.txt'; header('Content-Type: text/plain'); header('Content-Disposition: attachment; filename=' . $fn); readfile($path); JFactory::getApplication()->close(); }