Exemplo n.º 1
0
function blog_list()
{
    $blogs = array();
    if ($blog_folder = opendir(realpath(BLOG_FOLDER))) {
        while (false !== ($category_name = readdir($blog_folder))) {
            if (preg_match('/^cate_/', $category_name)) {
                if ($category_folder = opendir(realpath(BLOG_FOLDER . '/' . $category_name))) {
                    while (false !== ($blog_serial = readdir($category_folder))) {
                        if (preg_match('/^\\./', $blog_serial)) {
                            continue;
                        }
                        $arr_serial = blog_parse_serial($blog_serial);
                        $blogs[] = array('serial' => $blog_serial, 'timestamp' => $arr_serial['timestamp'], 'category' => substr($category_name, 5));
                    }
                    closedir($category_folder);
                } else {
                    return false;
                }
            }
        }
        closedir($blog_folder);
        return $blogs;
    } else {
        return false;
    }
}
Exemplo n.º 2
0
function archive_list()
{
    $hash_archive_list = array();
    $arr_archive_list = array();
    if ($blog_folder = opendir(realpath(BLOG_FOLDER))) {
        while (false !== ($category_name = readdir($blog_folder))) {
            if (preg_match('/^cate_/', $category_name)) {
                if ($category_folder = opendir(realpath(BLOG_FOLDER . '/' . $category_name))) {
                    while (false !== ($blog_serial = readdir($category_folder))) {
                        if (preg_match('/^\\./', $blog_serial)) {
                            continue;
                        }
                        $arr_serial = blog_parse_serial($blog_serial);
                        $hash_archive_list[date('M Y', $arr_serial['timestamp'])] = date('M Y', $arr_serial['timestamp']);
                    }
                    closedir($category_folder);
                }
            }
        }
        closedir($blog_folder);
        if (!empty($hash_archive_list)) {
            foreach ($hash_archive_list as $key => $archive_date) {
                $arr_archive_list[] = $archive_date;
            }
        }
        return $arr_archive_list;
    } else {
        return false;
    }
}