public function generate() { $galleryClassFile = IPSLib::getAppDir('gallery') . '/sources/classes/gallery.php'; if (!IPSLib::appIsInstalled('gallery') || $this->settings['sitemap_priority_gallery_albums'] == 0 || !is_file($galleryClassFile)) { return; } $classToLoad = IPSLib::loadLibrary($galleryClassFile, 'ipsGallery', 'gallery'); $this->registry->setClass('gallery', new $classToLoad($this->registry)); $limitCount = 0; while (1) { if (ipSeo_SitemapGenerator::isCronJob()) { sleep(0.5); } $filters = array('sortOrder' => 'desc', 'sortKey' => 'date', 'offset' => $limitCount, 'limit' => 100, 'isViewable' => true, 'memberData' => array('member_id' => 0)); $albums = $this->registry->gallery->helper('albums')->fetchAlbumsByFilters($filters); foreach ($albums as $album) { $url = "{$this->settings['board_url']}/index.php?app=gallery&album={$album['album_id']}"; $url = ipSeo_FURL::build($url, 'none', $album['album_name_seo'], 'viewalbum'); $addedCount = $this->sitemap->addUrl($url, $album['album_last_img_date'], $this->settings['sitemap_priority_gallery_albums']); } $limitCount += 100; if (count($albums) < 100) { break; } } }
public function generate() { $galleryClassFile = IPSLib::getAppDir('gallery') . '/sources/classes/gallery.php'; if (!IPSLib::appIsInstalled('gallery') || $this->settings['sitemap_priority_gallery_images'] == 0 || !is_file($galleryClassFile)) { return; } $classToLoad = IPSLib::loadLibrary($galleryClassFile, 'ipsGallery', 'gallery'); $this->registry->setClass('gallery', new $classToLoad($this->registry)); $max = $this->settings['sitemap_count_gallery_images']; if (!ipSeo_SitemapGenerator::isCronJob() && ($max > 10000 || $max == -1)) { $max = 10000; } elseif (ipSeo_SitemapGenerator::isCronJob() && $max == -1) { $max = 500000000; } $addedCount = 0; $limitCount = 0; while ($addedCount < $max) { if (ipSeo_SitemapGenerator::isCronJob()) { sleep(0.5); } $filters = array('sortOrder' => 'desc', 'sortKey' => 'date', 'offset' => $limitCount, 'limit' => 100, 'getLatestComment' => 1); $memberId = 0; $images = $this->registry->gallery->helper('image')->fetchImages($memberId, $filters); foreach ($images as $image) { $url = "{$this->settings['board_url']}/index.php?app=gallery&image={$image['image_id']}"; $url = ipSeo_FURL::build($url, 'none', $image['image_caption_seo'], 'viewimage'); $lastMod = is_null($image['comment_post_date']) ? $image['image_date'] : $image['comment_post_date']; $addedCount = $this->sitemap->addUrl($url, $lastMod, $this->settings['sitemap_priority_gallery_images']); } $limitCount += 100; if (count($images) < 100) { break; } } }
public function generate() { if (!IPSLib::appIsInstalled('downloads') || $this->settings['sitemap_priority_downloads_files'] == 0) { return; } $addedCount = 0; $limitCount = 0; while ($addedCount < $this->settings['sitemap_count_downloads_files']) { if (ipSeo_SitemapGenerator::isCronJob()) { sleep(0.5); } // Get files: $permCheck = $this->DB->buildWherePermission(array($this->caches['group_cache'][$this->settings['guest_group']]['g_perm_id']), 'p.perm_2', true); $this->DB->build(array('select' => 'f.file_id, f.file_name_furl, f.file_updated', 'from' => array('downloads_files' => 'f'), 'add_join' => array(array('from' => array('downloads_categories' => 'c'), 'where' => "c.cid = f.file_cat", 'type' => 'left'), array('from' => array('permission_index' => 'p'), 'where' => "(p.app = 'downloads' AND p.perm_type = 'cat' AND p.perm_type_id = c.cid)", 'type' => 'left')), 'where' => "f.file_broken = 0 AND file_open = 1 AND c.copen = 1 AND ({$permCheck})", 'order' => 'f.file_updated DESC', 'limit' => array($limitCount, 100))); $result = $this->DB->execute(); // Add blogs to sitemap: while ($file = $this->DB->fetch($result)) { if (!$file['file_updated']) { $file['file_updated'] = $file['file_submitted']; } $url = $this->settings['board_url'] . '/index.php?app=downloads&showfile=' . $file['file_id']; $url = ipSeo_FURL::build($url, 'none', $file['file_name_furl'], 'idmshowfile'); //$url = ipsRegistry::getClass('output')->buildSEOUrl($url, 'none', $file['file_name_furl'], 'idmshowfile'); $addedCount = $this->sitemap->addURL($url, $file['file_updated'], $this->settings['sitemap_priority_downloads_files']); } $limitCount += 100; // If we've got back less rows than expected, we've probably got no more to pull: if ($this->DB->getTotalRows($result) < 100) { break; } } }
public function generate() { if (!IPSLib::appIsInstalled('blog') || $this->settings['sitemap_priority_blog_entries'] == 0) { return; } // Check whether groups can access blog at all: $guestGroup = $this->DB->buildAndFetch(array('select' => 'g_blog_settings', 'from' => 'groups', 'where' => 'g_id = ' . $this->settings['guest_group'])); // Default is to not allow access unless explicitly given: if (is_null($guestGroup['g_blog_settings'])) { return; } $settings = unserialize($guestGroup['g_blog_settings']); // Not allowed to access unless g_blog_allowview = 1 if (!is_array($settings) || intval($settings['g_blog_allowview']) != 1) { return; } $max = $this->settings['sitemap_count_blog_entries']; if (!ipSeo_SitemapGenerator::isCronJob() && ($max > 10000 || $max == -1)) { $max = 10000; } elseif (ipSeo_SitemapGenerator::isCronJob() && $max == -1) { $max = 50000000; } // Get blogs: $addedCount = 0; $limitCount = 0; while ($addedCount < $max) { if (ipSeo_SitemapGenerator::isCronJob()) { sleep(0.25); } $query = $this->DB->build(array('select' => 'e.entry_id, b.blog_id, e.entry_name_seo, e.entry_last_update', 'from' => array('blog_entries' => 'e'), 'add_join' => array(array('type' => 'left', 'from' => array('blog_blogs' => 'b'), 'where' => 'b.blog_id = e.blog_id')), 'where' => 'b.blog_private = 0 AND b.blog_disabled = 0 AND b.blog_allowguests = 1 AND b.blog_view_level = \'public\' AND e.entry_status = \'published\'', 'order' => 'e.entry_id DESC', 'limit' => array($limitCount, 100))); $outer = $this->DB->execute(); // Add blogs to sitemap: while ($entry = $this->DB->fetch($outer)) { $url = $this->settings['board_url'] . '/index.php?app=blog&module=display§ion=blog&blogid=' . $entry['blog_id'] . '&showentry=' . $entry['entry_id']; $url = ipSeo_FURL::build($url, 'none', $entry['entry_name_seo'], 'showentry'); //$url = ipsRegistry::getClass('output')->buildSEOUrl($url, 'none', $entry['entry_name_seo'], 'showentry'); $addedCount = $this->sitemap->addURL($url, $entry['entry_last_update'], $this->settings['sitemap_priority_blog_entries']); unset($url); unset($entry); } $limitCount += 100; // If we've got back less rows than expected, we've probably got no more to pull: if ($this->DB->getTotalRows($outer) < 100) { break; } } }
public function generate() { if (!IPSLib::appIsInstalled('ccs') || $this->settings['sitemap_priority_content_records'] == 0) { return; } $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('ccs') . '/sources/functions.php', 'ccsFunctions', 'ccs'); $databaseToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('ccs') . '/sources/databases.php', 'databaseBuilder', 'ccs'); $ccsFunctions = new $classToLoad($this->registry); $permCheck1 = $this->DB->buildWherePermission(array($this->caches['group_cache'][$this->settings['guest_group']]['g_perm_id']), 'perm1.perm_2', true); $permCheck2 = $this->DB->buildWherePermission(array($this->caches['group_cache'][$this->settings['guest_group']]['g_perm_id']), 'perm2.perm_2', true); $permCheck3 = $this->DB->buildWherePermission(array($this->caches['group_cache'][$this->settings['guest_group']]['g_perm_id']), 'p.page_view_perms', true); $this->DB->build(array('select' => 'c.category_id, d.*, p.*', 'from' => array('ccs_database_categories' => 'c'), 'add_join' => array(array('from' => array('ccs_databases' => 'd'), 'where' => "d.database_id = c.category_database_id", 'type' => 'left'), array('from' => array('ccs_pages' => 'p'), 'where' => "(\td.database_is_articles = 0 \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND p.page_content LIKE CONCAT('%parse database=\"', d.database_key, '\"%') \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tOR \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(\td.database_is_articles = 1 \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND p.page_content LIKE '%\\{parse articles\\}%'))", 'type' => 'left'), array('from' => array('permission_index' => 'perm1'), 'where' => "(perm1.app = 'ccs' AND \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(perm1.perm_type = 'databases' OR perm1.perm_type = 'database') AND \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tperm1.perm_type_id = d.database_id)", 'type' => 'left'), array('from' => array('permission_index' => 'perm2'), 'where' => "(perm2.app = 'ccs' AND \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(perm2.perm_type = 'categories' OR perm2.perm_type = 'cat') AND \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tperm2.perm_type_id = c.category_id)", 'type' => 'left')), 'where' => "\t{$permCheck1} AND \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t(perm2.perm_2 IS NULL OR perm2.perm_2 = '' OR perm2.perm_2=',,' OR {$permCheck2}) AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t({$permCheck3})", 'order' => 'category_id DESC')); $result = $this->DB->execute(); $categories = array(); $databases = array(); while ($category = $this->DB->fetch($result)) { $categories[$category['category_id']] = $category['category_id']; $databases[$category['database_id']] = $category; $databases[$category['database_id']]['base_link'] = $ccsFunctions->returnPageUrl($category) . '?'; } $_databases = $this->cache->getCache('ccs_databases'); foreach ($_databases as $_db) { if (isset($databases[$_db['database_id']])) { continue; } if (ipsRegistry::getClass('permissions')->check('view', $_db, explode(',', $this->caches['group_cache'][$this->settings['guest_group']]['g_perm_id'])) != TRUE) { $databases[$_db['database_id']] = $_db; $databases[$_db['database_id']]['base_link'] = $ccsFunctions->returnDatabaseUrl($_db['database_id']); } } /*if(!count($categories)) { return; }*/ $_cats = count($categories) ? implode(',', $categories) : 0; $_hardLimit = !ipSeo_SitemapGenerator::isCronJob() ? 10000 : 500000000; $addedCount = 0; foreach ($databases as $database) { if (ipSeo_SitemapGenerator::isCronJob()) { sleep(1); //print 'Processing database: ' . $database['database_name'] . PHP_EOL; } $db = new $databaseToLoad($this->registry); $db->categories = $ccsFunctions->getCategoriesClass($database['database_id'], false); $db->database = $database; $db->fieldsClass = $this->registry->ccsFunctions->getFieldsClass(); $limitCount = 0; while (1) { if (ipSeo_SitemapGenerator::isCronJob()) { sleep(0.25); } if ($addedCount >= $_hardLimit) { break; } $_published = null; if ($database['database_is_articles']) { $_cache = $this->cache->getCache('ccs_fields'); foreach ($_cache[$database['database_id']] as $_field) { if ($_field['field_key'] == 'article_date') { $_published = 'field_' . $_field['field_id']; } } } $this->DB->build(array('select' => '*', 'from' => $database['database_database'], 'where' => 'record_approved = 1 AND ( category_id IN (' . $_cats . ') OR category_id=0)', 'order' => 'record_updated DESC', 'limit' => array($limitCount, 100))); $result = $this->DB->execute(); while ($record = $this->DB->fetch($result)) { if ($database['database_is_articles'] and $record[$_published] > time()) { continue; } $record['_skipUpdateDynamic'] = true; $url = $db->getRecordUrl($record); $addedCount = $this->sitemap->addUrl($url, (int) $record['record_updated'], $this->settings['sitemap_priority_content_records']); } $limitCount += 100; // If we've got back less rows than expected, we've probably got no more to pull: if ($this->DB->getTotalRows($result) < 100) { break; } } } }
public function generate() { if ($this->settings['sitemap_priority_topics'] == 0) { return; } $maxTopics = (int) ipsRegistry::$settings['sitemap_recent_topics']; if (!ipSeo_SitemapGenerator::isCronJob() && ($maxTopics > 10000 || $maxTopics == -1)) { $maxTopics = 10000; } elseif (ipSeo_SitemapGenerator::isCronJob() && $maxTopics == -1) { $maxTopics = 50000000; } $curTopics = 0; $limitTopics = 0; if (ipSeo_SitemapGenerator::isCronJob()) { //print 'Done: '; } while ($curTopics < $maxTopics) { if (ipSeo_SitemapGenerator::isCronJob()) { //print $curTopics . ', '; sleep(0.5); } $permCheck = $this->DB->buildWherePermission(array($this->caches['group_cache'][$this->settings['guest_group']]['g_perm_id']), 'p.perm_2', true); $this->DB->build(array('select' => 't.*, f.ipseo_priority', 'from' => array('topics' => 't'), 'add_join' => array(array('from' => array('permission_index' => 'p'), 'where' => "(p.perm_type = 'forum' AND p.perm_type_id = t.forum_id)", 'type' => 'left'), array('from' => array('forums' => 'f'), 'where' => "f.id=t.forum_id", 'type' => 'left')), 'where' => "{$permCheck} AND " . $this->registry->getClass('class_forums')->fetchTopicHiddenQuery(array('visible'), ''), 'limit' => array($limitTopics, 100))); $result = $this->DB->execute(); if ($result) { /*$_one = 0; $_two = 0; $_three = 0;*/ // Add the resulting rows to the sitemap: while ($row = $this->DB->fetch($result)) { if ($row['ipseo_priority'] == '0') { continue; } if (!$this->settings['sitemap_topic_pages'] || $row['posts'] <= $this->settings['display_max_posts']) { $url = $this->settings['board_url'] . '/index.php?showtopic=' . $row['tid']; $url = ipSeo_FURL::build($url, 'none', $row['title_seo'], 'showtopic'); //$url = ipsRegistry::getClass('output')->buildSEOUrl($url, 'none', $row['title_seo'], 'showtopic'); if ($this->settings['sitemap_priority_topics'] == 100) { $priority = $this->calculatePriority($row); } else { $priority = $this->settings['sitemap_priority_topics']; } $curTopics = $this->sitemap->addURL($url, $row['last_post'], $priority); } else { $j = 1; for ($i = 0; $i <= $row['posts']; $i += $this->settings['display_max_posts']) { $url = $this->settings['board_url'] . '/index.php?showtopic=' . $row['tid'] . ($j == 1 ? '' : '&page=' . $j); $url = ipSeo_FURL::build($url, 'none', $row['title_seo'], 'showtopic'); //$url = ipsRegistry::getClass('output')->buildSEOUrl($url, 'none', $row['title_seo'], 'showtopic'); if ($this->settings['sitemap_priority_topics'] == 100) { $priority = $this->calculatePriority($row, true); } else { $priority = $this->settings['sitemap_priority_topics']; } $curTopics = $this->sitemap->addURL($url, $row['last_post'], $priority); $j++; } } /*$_one += $one; $_two += $two; $_three += $three;*/ } $limitTopics += 100; // If we've got back less rows than expected, we've probably got no more to pull: if ($this->DB->getTotalRows($result) < 100) { break; } } } if (ipSeo_SitemapGenerator::isCronJob()) { //print PHP_EOL; } }