root/branches/portal_by_daris/include/cache.php

Revision 5, 1.4 KB (checked in by daris, 3 years ago)

portal: language files review

Line 
1<?php
2/***********************************************************************
3
4        PunBB extension
5        Portal
6        Daris <daris91@gmail.com>
7
8************************************************************************/
9
10
11// Make sure no one attempts to run this script "directly"
12if (!defined('FORUM'))
13        exit;
14
15function generate_panels_cache()
16{
17        global $forum_db;
18
19        // Get the forum config from the DB
20        $query = array(
21                'SELECT'        => 'pn.*',
22                'FROM'          => 'panels AS pn',
23                'WHERE'         => 'pn.enable=1',
24                'ORDER BY'      => 'pn.location, pn.position'
25        );
26
27        ($hook = get_hook('xn_portal_by_daris_ch_qr_get_panels')) ? eval($hook) : null;
28        $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
29
30        $output = array();
31        while ($cur_panel = $forum_db->fetch_assoc($result))
32        {
33                if (!isset($output[$cur_panel['location']]))
34                        $output[$cur_panel['location']] = array();
35               
36                $output[$cur_panel['location']][] = array(
37                        'name' => $cur_panel['name'],
38                        'position' => $cur_panel['position'],
39                        'content' => $cur_panel['content'],
40                        'file' => $cur_panel['file']
41                );
42        }
43
44        // Output config as PHP code
45        $fh = @fopen(FORUM_CACHE_DIR.'cache_panels.php', 'wb');
46        if (!$fh)
47                error('Unable to write configuration cache file to cache directory. Please make sure PHP has write access to the directory \'cache\'.', __FILE__, __LINE__);
48
49        fwrite($fh, '<?php'."\n\n".'define(\'FORUM_PANELS_LOADED\', 1);'."\n\n".'$forum_panels = '.var_export($output, true).';'."\n\n".'?>');
50
51        fclose($fh);
52}
Note: See TracBrowser for help on using the browser.