Пример #1
0
/**
 * @desc Update indexes
 * @warning Call directy this file.
 */
function load_archive_index($files)
{
    $arhive_index = array();
    foreach ($files as $idx) {
        $arhive_index[$idx] = db_index_load(pathinfo($idx, PATHINFO_FILENAME));
    }
    return $arhive_index;
}
Пример #2
0
function dashboard_archives()
{
    list($req_archive_id, $arch_action, $last_only, $period) = GET('archive_id, arch_action, last_only, period');
    // Do make archive
    if (request_type('POST')) {
        cn_dsi_check();
        // Archives actions
        if ($req_archive_id) {
            // Delete
            if ($arch_action == 'rm') {
                db_archive_meta_update($req_archive_id, 0, 0, 0);
                $req_archive_id = 0;
                cn_throw_message("Archive deleted", 'e');
            } elseif ($arch_action == 'extr') {
                if (!db_extract_archive($req_archive_id)) {
                    cn_throw_message("Archive not extracted correctly", 'e');
                } else {
                    $req_archive_id = 0;
                    cn_throw_message("Archive extracted");
                }
            } else {
                cn_throw_message('@SYSINFO: Unrecognized request', 'e');
            }
        } else {
            if ($last_only) {
                $date_f = ctime() - $period * 3600 * 24;
                $date_t = ctime();
            } else {
                list($_fd, $_fm, $_fy) = GET('from_date_day, from_date_month, from_date_year', 'POST');
                list($_td, $_tm, $_ty) = GET('to_date_day, to_date_month, to_date_year', 'POST');
                $date_f = mktime(0, 0, 0, intval($_fm), intval($_fd), intval($_fy));
                $date_t = mktime(23, 59, 59, intval($_tm), intval($_td), intval($_ty));
            }
            $cc = db_make_archive($date_f, $date_t);
            if ($cc) {
                cn_throw_message(i18n('Archive created (%1 articles)', $cc));
            } else {
                cn_throw_message('There is nothing to archive', 'e');
            }
        }
    }
    // --- archives
    $arch_list = db_get_archives();
    // ---- fetch active ---
    $ids = db_index_load();
    ksort($ids);
    reset($ids);
    $st = key($ids);
    end($ids);
    $ed = key($ids);
    list($f_date_d, $f_date_m, $f_date_y) = make_postponed_date($st);
    list($t_date_d, $t_date_m, $t_date_y) = make_postponed_date($ed);
    cn_assign('arch_list, archive_id', $arch_list, $req_archive_id);
    cn_assign('f_date_d, f_date_m, f_date_y, t_date_d, t_date_m, t_date_y', $f_date_d, $f_date_m, $f_date_y, $t_date_d, $t_date_m, $t_date_y);
    echoheader('-@dashboard/style.css', 'Arhives');
    echo exec_tpl('dashboard/archives');
    echofooter();
}
Пример #3
0
                 $url = cn_url_modify($_static_qr, 'id=' . $id);
             }
         }
         $itemid++;
         echo "<div class='cutenews_search_item'>{$itemid} <b><a href='{$url}'>{$title}</a></b> (" . date("d F, Y", $id) . ")</div>";
         $_number--;
         if ($_number == 0) {
             $_next_link = TRUE;
             break 2;
         }
     }
     // Next archive, if present
     if ($archives && count($_list_archives)) {
         $archive_id = key($_list_archives);
         // Load ID from archives
         $news = array_keys(db_index_load("archive-{$archive_id}"));
         krsort($news);
         unset($_list_archives[$archive_id]);
     } else {
         break;
     }
 } while (TRUE);
 // show results ------------
 if (!$found) {
     echo "<p class='cutenews_not_match'>" . i18n('There are no news articles matching your search criteria') . "</p>";
 } else {
     // Close "cn_search_body"
     echo "</div>";
 }
 echo '<div class="cn_paginate_search">';
 $__PHP_SELF = $PHP_SELF;
Пример #4
0
function edit_news_delete()
{
    cn_dsi_check();
    if (!test('Nud')) {
        msg_info("Unable to delete news: no permission");
    }
    $FlatDB = new FlatDB();
    list($id, $source) = GET('id, source', 'GET');
    $ida = db_index_load($source);
    $nloc = db_get_nloc($id);
    $db = db_news_load($nloc);
    // ------
    $FlatDB->cn_remove_categories($db[$id]['c'], $db[$id]['id']);
    $FlatDB->cn_update_date(0, $db[$id]['id']);
    $FlatDB->cn_user_sync($db[$id]['u'], 0, $db[$id]['id']);
    $FlatDB->cn_remove_tags($db[$id]['tg'], $db[$id]['id']);
    // ------
    unset($db[$id]);
    unset($ida[$id]);
    // Remove from meta-index
    $_ts_id = bt_get_id($id, 'nts_id');
    bt_del_id($id, 'nts_id');
    bt_del_id($_ts_id, 'nid_ts');
    // Remove page alias
    $_ts_pg = bt_get_id($id, 'ts_pg');
    bt_del_id($id, 'ts_pg');
    bt_del_id($_ts_pg, 'pg_ts');
    // save block
    db_save_news($db, $nloc);
    db_index_save($ida, $source);
    db_index_update_overall($source);
    cn_relocation(cn_url_modify(array('reset'), 'mod=editnews', "source={$source}"));
    $FlatDB->cache_clean();
}