/** * Первый запуск модуля */ protected static function first_run() { // (1) IndexerSecretKey self::save_setting('IndexerSecretKey', sha1(mt_rand() . time())); // (2) robots.txt sitemap link $robots = new nc_search_robots(); $path = self::get_module_url(); foreach (array_keys(nc_Core::get_object()->catalogue->get_all()) as $site_id) { $robots->add_directive($site_id, "Sitemap: {$path}/sitemap.php"); $robots->save_robots_txt($site_id); } // (3) инициализация поисковой службы self::get_provider()->first_run(); }
/** * */ protected function get_robots_txt_area_parts() { $disallowed = array(); $robots_parser = new nc_search_robots(); $site_ids = array_keys(nc_Core::get_object()->catalogue->get_all()); foreach ($site_ids as $site_id) { $site_area = array(new nc_search_area_site(array('id' => $site_id))); $robots = $robots_parser->get_directives($site_id); $all = array(); foreach ($robots["allow"] as $url) { $all[$url] = true; } foreach ($robots["disallow"] as $url) { $all[$url] = false; } ksort($all); foreach ($all as $url => $is_excluded) { $url = rawurldecode($url); if (strpos($url, "*") !== false || strpos($url, "\$") !== false) { $regexp = preg_quote($url, '@'); $regexp = str_replace("\\*", ".+", $regexp); $regexp = str_replace("\\\$", "\$", $regexp); $disallowed[] = new nc_search_area_regexp(array('regexp' => "@{$regexp}@u", 'is_excluded' => $is_excluded, 'sites' => $site_area)); } else { $disallowed[] = new nc_search_area_page(array('url' => $url, 'is_excluded' => $is_excluded, 'include_descendants' => true, 'sites' => $site_area)); } } } return $disallowed; }