$sitemap_where['begin'] = array('begin', cot::$sys['now'], '<=');
$sitemap_where['expire'] = array('SQL', "expire = 0 OR expire > " . cot::$sys['now']);
/* === Hook === */
foreach (cot_getextplugins('sitemap.advboard.query') as $pl) {
    include $pl;
}
/* ===== */
$condition = array();
foreach ($sitemap_where as $key => $val) {
    $condition[] = $val;
}
$order = array(array('sort', 'DESC'));
$cnt = advboard_model_Advert::count($condition);
if ($cnt > 0) {
    $i = 0;
    while ($i <= $cnt) {
        $advertisement = advboard_model_Advert::find($condition, 20, $i, $order);
        if (!$advertisement) {
            break;
        }
        foreach ($advertisement as $advert) {
            $i++;
            if (!$auth_cache[$advert->category]) {
                continue;
            }
            sitemap_parse($t, $items, array('url' => $advert->url, 'date' => !empty($advert->updated) ? strtotime($advert->updated) : '', 'freq' => cot::$cfg['plugin']['sitemap']['freq'], 'prio' => cot::$cfg['plugin']['sitemap']['prio']));
            unset($advert);
        }
        unset($advertisement);
    }
}
Beispiel #2
0
    if ($cfg['plugin']['sitemap']['users'] && cot_module_active('users') && cot_auth('users', 'a', 'R')) {
        // Sitemap for users module
        require_once cot_incfile('users', 'module');
        // User profiles
        $sitemap_join_columns = '';
        $sitemap_join_tables = '';
        $sitemap_where = array();
        /* === Hook === */
        foreach (cot_getextplugins('sitemap.users.query') as $pl) {
            include $pl;
        }
        /* ===== */
        $sitemap_where = count($sitemap_where) > 0 ? 'WHERE ' . join(' AND ', $sitemap_where) : '';
        $res = $db->query("SELECT u.user_id, u.user_name {$sitemap_join_columns}\n\t\t\tFROM {$db_users} AS u {$sitemap_join_tables}\n\t\t\t{$sitemap_where}\n\t\t\tORDER BY user_id");
        foreach ($res->fetchAll() as $row) {
            sitemap_parse($t, $items, array('url' => cot_url('users', array('m' => 'details', 'id' => $row['user_id'], 'u' => $row['user_name'])), 'date' => '', 'freq' => $cfg['plugin']['sitemap']['users_freq'], 'prio' => $cfg['plugin']['sitemap']['users_prio']));
        }
    }
    /* === Hook === */
    foreach (cot_getextplugins('sitemap.main') as $pl) {
        include $pl;
    }
    /* ===== */
    // Save the last page
    $t->parse();
    sitemap_save($t->text(), (int) ceil($items / $perpage) - 1);
    // Save count file
    file_put_contents($count_file, $items);
}
if ($a == 'index') {
    // Show sitemap index
        $auth_cache[$c] = cot_auth('folio', $c, 'R');
        if (!$auth_cache[$c]) {
            continue;
        }
        sitemap_parse($t, $items, array('url' => cot_url('folio', "c={$c}"), 'date' => '', 'freq' => $cfg['folio']['foliositemap_freq'], 'prio' => $cfg['folio']['foliositemap_prio']));
    }
    // Projects
    $sitemap_join_columns = '';
    $sitemap_join_tables = '';
    $sitemap_where = array();
    $sitemap_where['state'] = 'item_state = 0';
    /* === Hook === */
    foreach (cot_getextplugins('folio.sitemap.query') as $pl) {
        include $pl;
    }
    /* ===== */
    $sitemap_where = count($sitemap_where) > 0 ? 'WHERE ' . join(' AND ', $sitemap_where) : '';
    $res = $db->query("SELECT f.item_id, f.item_alias, f.item_cat {$sitemap_join_columns}\n\t\tFROM {$db_folio} AS f {$sitemap_join_tables}\n\t\t{$sitemap_where}\n\t\tORDER BY f.item_cat, f.item_id");
    foreach ($res->fetchAll() as $row) {
        if (!$auth_cache[$row['item_cat']]) {
            continue;
        }
        $urlp = array('c' => $row['item_cat']);
        if (!empty($row['item_alias'])) {
            $urlp['al'] = $row['item_alias'];
        } else {
            $urlp['id'] = $row['item_id'];
        }
        sitemap_parse($t, $items, array('url' => cot_url('folio', $urlp), 'date' => $row['item_date'], 'freq' => $cfg['folio']['foliositemap_freq'], 'prio' => $cfg['folio']['foliositemap_prio']));
    }
}