예제 #1
0
/**
 * Frontend Functions, Furasta.Org
 *
 * Contains functions which are loaded in
 * the frontend of the CMS only.
 *
 * @author     Conor Mac Aoidh <*****@*****.**>
 * @license    http://furasta.org/licence.txt The BSD License
 * @version    1.0
 * @package    frontend
 */
function frontend_menu()
{
    $cache_file = md5('FURASTA_FUNCTION_FRONTEND_MENU');
    if (cache_is_good($cache_file, '120*60*12', 'PAGES')) {
        $order = json_decode(cache_get($cache_file, 'PAGES'));
    } else {
        $pages = array();
        $query = query('select id,name,parent,slug,home from ' . DB_PAGES . ' where display=1 order by position,name desc');
        while ($row = mysql_fetch_assoc($query)) {
            $pages[$row['parent']][] = $row;
        }
        $order = frontend_list_pages(0, $pages, 0, SITE_URL);
        cache($cache_file, json_encode($order), 'PAGES');
    }
    return $order;
}
예제 #2
0
/**
 * pages_array
 *
 * returns a cached version of the pages array in the format
 * $pages[ id ] = name; it also has system restricted pagenames
 * at the end of the array
 * 
 * @access public
 * @return array
 */
function pages_array()
{
    $cache_file = md5('FURASTA_ADMIN_PAGES_ARRAY');
    if (cache_is_good($cache_file, 'PAGES')) {
        return json_decode(cache_get($cache_file, 'PAGES'));
    }
    /**
     * get page names from database 
     */
    $pages = array();
    $query = mysql_query('select id,name from ' . DB_PAGES);
    while ($row = mysql_fetch_array($query)) {
        $pages[$row['id']] = $row['name'];
    }
    /**
     * system names already in use 
     */
    $pages[] = 'admin';
    $pages[] = 'install';
    $pages[] = '_inc';
    $pages[] = '_www';
    $pages[] = '_plugins';
    $pages[] = '_user';
    /**
     * cache and return pages array
     */
    cache($cache_file, json_encode($pages), 'PAGES');
    return $pages;
}
예제 #3
0
        $content .= '<table class="row-color">';
        $pages = rows('select id,name,content,edited from ' . DB_TRASH . ' order by edited desc limit 5');
        if (count($pages) == 0) {
            $content .= '<p><i>No items in trash!</i></p>';
            break;
        }
        foreach ($pages as $page) {
            $content .= '<tr><td><span>' . date("F j,Y", strtotime($page['edited'])) . '</span><a
		        href="pages.php?page=edit&id=' . $page['id'] . '"><h3>' . $page['name'] . '</h3></a>
		        <p>' . strip_tags(substr($page['content'], 0, 125)) . ' [...]</p></td></tr>';
        }
        $content .= '</table>';
        break;
    case 'furasta-devblog':
        $cache_file = md5('FURASTA_RSS_DEVBLOG');
        if (cache_is_good($cache_file, '60 * 60 * 24 * 3', 'RSS')) {
            $items = json_decode(cache_get($cache_file, 'RSS'), true);
        } else {
            $elements = rss_fetch('http://blog.macaoidh.name/tag/furasta-org/feed/');
            if ($elements == false) {
                $content .= '<p><i>Could not fetch feed.</i></p>';
                break;
            }
            $items = array();
            for ($i = 0; $i <= 2; $i++) {
                foreach ($elements[$i] as $element => $value) {
                    switch ($element) {
                        case 'pubDate':
                            $items[$i]['pubDate'] = date("F j, Y", strtotime($value));
                            break;
                        case 'title':