function MainController(&$_plugin_api) { if (is_dir('installer') && !cfg('ignore_installer_dir', FALSE)) { die('Error: Please delete the installer/ directory before using this forum.'); } if (cfg_is('salt', '')) { die('Error: Please define the salt variable in config.inc.php!'); } $this->api = $_plugin_api; trace(); }
function show() { $days = cfg('statistics_timespan'); $resolution = 60 * 60 * 24; $end = strtotime(strftime('%Y-%m-%d')) + 60 * 60 * 24; $start = $end - 60 * 60 * 24 * $days; $results = array(); // Read CSV data, if any. if (!cfg_is('statistics_traffic_data', '')) { $traffic = $this->_read_csv(cfg('statistics_traffic_data')); } if (!cfg_is('statistics_extra_data', '')) { $postings2 = $this->_read_csv(cfg('statistics_extra_data')); } // Collect the number of postings per day within the specified period. for ($day_end = $start; $day_end <= $end; $day_end += $resolution) { $day_start = $day_end - $resolution; $date = strftime('%Y-%m-%d', $day_start); $result = (object) array(); $result->pos = (int) ($day_end - $start) / $resolution; $result->postings = (int) $this->forumdb->get_n_postings(NULL, $day_start, $day_end); $result->postings2 = (int) $postings2[$date]; $result->traffic = (int) $traffic[$date] / 1000000; array_push($results, $result); $result = null; } $this->clear_all_assign(); $this->assign('plugin_dir', 'plugins/statistics'); $this->assign('show_traffic', $traffic ? TRUE : FALSE); $this->assign('show_postings2', $postings2 ? TRUE : FALSE); $this->assign_by_ref('days', $days); $this->assign_by_ref('resolution', $resolution); $this->assign_by_ref('data', $results); $this->assign('postings2_label', cfg('statistics_extra_label')); $this->render_php(dirname(__FILE__) . '/statistics.php.tmpl'); $this->api->set_title(_('Statistics')); }