Beispiel #1
0
 public function uninstall($parent)
 {
     require_once JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_aimysitemap' . DIRECTORY_SEPARATOR . 'Sitemap.php';
     JFactory::getLanguage()->load('com_aimysitemap', JPATH_ADMINISTRATOR);
     $sm = new AimySitemapSitemap();
     $sm->unlink_file_if_exists();
 }
Beispiel #2
0
 public function write()
 {
     JSession::checkToken() or jexit(JText::_('INVALID TOKEN'));
     $rights = AimySitemapRightsHelper::getRights();
     if (!$rights->get('aimysitemap.write')) {
         $this->setError(JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'));
         $this->setMessage($this->getError(), 'error');
     } else {
         require_once JPATH_COMPONENT . DIRECTORY_SEPARATOR . 'Sitemap.php';
         $sm = new AimySitemapSitemap();
         $sm->write_sitemap_file();
     }
     $this->setRedirect(JRoute::_('index.php?option=com_aimysitemap&view=urls', false));
 }
Beispiel #3
0
 public function crawl_ajax()
 {
     JSession::checkToken() or jexit(JText::_('INVALID TOKEN'));
     $rights = AimySitemapRightsHelper::getRights();
     if (!$rights->get('aimysitemap.crawl')) {
         jexit(JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'));
     }
     header('Content-Type: application/json; charset=UTF-8');
     $crawler = new AimySitemapCrawler();
     $res = null;
     try {
         $res = $crawler->crawl();
     } catch (Exception $e) {
         AimySitemapLogger::error("Crawl-Ctrl: Exception: {$e}");
         error_log("{$e}");
         echo json_encode(array('ok' => false, 'msg' => $e->getMessage())), "\n";
         return JFactory::getApplication()->close();
     }
     if (isset($res['url'])) {
         AimySitemapLogger::debug('Crawl: done' . (isset($res['msg']) ? ': ' . $res['msg'] : ''));
     }
     if (isset($res['abort']) && $res['abort']) {
         AimySitemapLogger::debug('Crawl: ' . (isset($res['ok']) && $res['ok'] ? 'finished' : 'aborted'));
         if (isset($res['ok']) && $res['ok']) {
             if (defined('JDEBUG') && JDEBUG) {
                 $res = array('ok' => 1, 'abort' => 1, 'msg' => JText::_('AIMY_SM_MSG_VIEW_LOG'), 'stats' => array());
             } else {
                 require_once JPATH_COMPONENT . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'kvstore.php';
                 if (AimySitemapKVStore::get('rebuilding')) {
                     $res = array('ok' => 1, 'msg' => JText::_('AIMY_SM_MSG_REBUILDING'), 'rebuilding' => 1);
                 } else {
                     AimySitemapKVStore::set('rebuilding', 1);
                     require_once JPATH_COMPONENT . DIRECTORY_SEPARATOR . 'Sitemap.php';
                     $sm = new AimySitemapSitemap();
                     $res['stats'] = $sm->rebuild();
                     AimySitemapCrawler::delete_crawl_data();
                     AimySitemapKVStore::delete('rebuilding');
                 }
             }
         }
     }
     echo json_encode($res), "\n";
     JFactory::getApplication()->close();
 }
Beispiel #4
0
 private static function initialize_jpagetitle_list()
 {
     $jlang = JFactory::getLanguage();
     $db = JFactory::getDbo();
     $langs = $jlang->getKnownLanguages();
     $jpts = array();
     foreach (array_keys($langs) as $lang) {
         $over_path = JPATH_SITE . DIRECTORY_SEPARATOR . 'language' . DIRECTORY_SEPARATOR . 'overrides' . DIRECTORY_SEPARATOR . "{$lang}.override.ini";
         if (JFile::exists($over_path)) {
             $cnt = @file_get_contents($over_path);
             if ($cnt !== false) {
                 $cnt = str_replace('_QQ_', '"\\""', $cnt);
                 $ors = @parse_ini_string($cnt);
                 if (is_array($ors)) {
                     if (isset($ors['JPAGETITLE']) && !empty($ors['JPAGETITLE'])) {
                         $jpts[$ors['JPAGETITLE']] = 1;
                         continue;
                     }
                 }
             }
         }
         $jo = JLanguage::getInstance($lang);
         if ($jo->load('joomla', JPATH_SITE)) {
             $jpt = $jo->_('JPAGETITLE');
             if (!empty($jpt)) {
                 $jpts[$jpt] = 1;
             }
         }
     }
     if (empty($jpts)) {
         $jpts['%1$s - %2$s'] = 1;
     }
     self::$jpagetitles = array_keys($jpts);
 }