function spa_save_display_data() { check_admin_referer('forum-adminform_display', 'forum-adminform_display'); $mess = spa_text('Display options updated'); $sfdisplay = sp_get_option('sfdisplay'); $sfcontrols = sp_get_option('sfcontrols'); # Page Title $sfdisplay['pagetitle']['notitle'] = isset($_POST['sfnotitle']); $sfdisplay['pagetitle']['banner'] = sp_filter_save_cleanurl($_POST['sfbanner']); # Stats $sfcontrols['shownewcount'] = isset($_POST['shownewcount']) ? sp_esc_int($_POST['shownewcount']) : 6; $newuserlist = sp_get_option('spRecentMembers'); if (is_array($newuserlist)) { $ccount = count($newuserlist); while ($ccount > $sfcontrols['shownewcount']) { array_pop($newuserlist); $ccount--; } sp_update_option('spRecentMembers', $newuserlist); } $sfcontrols['showtopcount'] = isset($_POST['showtopcount']) ? sp_esc_int($_POST['showtopcount']) : 6; # adjust stats interval $statsInterval = !empty($_POST['statsinterval']) ? sp_esc_str($_POST['statsinterval']) * 3600 : 3600; $oldStatsInterval = sp_get_option('sp_stats_interval') * 3600; if ($statsInterval != $oldStatsInterval) { sp_update_option('sp_stats_interval', $statsInterval); wp_clear_scheduled_hook('sph_stats_cron'); wp_schedule_event(time(), 'sp_stats_interval', 'sph_stats_cron'); } # unread posts $sfcontrols['sfdefunreadposts'] = is_numeric($_POST['sfdefunreadposts']) ? max(0, sp_esc_int($_POST['sfdefunreadposts'])) : 50; $sfcontrols['sfusersunread'] = isset($_POST['sfusersunread']); $sfcontrols['sfmaxunreadposts'] = is_numeric($_POST['sfmaxunreadposts']) ? max(0, sp_esc_int($_POST['sfmaxunreadposts'])) : $sfcontrols['sfdefunreadposts']; include_once SF_PLUGIN_DIR . '/forum/database/sp-db-statistics.php'; $topPosters = sp_get_top_poster_stats((int) $sfcontrols['showtopcount']); sp_update_option('spPosterStats', $topPosters); $sfdisplay['forums']['singleforum'] = isset($_POST['sfsingleforum']); $sfdisplay['topics']['perpage'] = isset($_POST['sfpagedtopics']) ? sp_esc_int($_POST['sfpagedtopics']) : 20; $sfdisplay['topics']['sortnewtop'] = isset($_POST['sftopicsort']); $sfdisplay['posts']['perpage'] = isset($_POST['sfpagedposts']) ? sp_esc_int($_POST['sfpagedposts']) : 20; $sfdisplay['posts']['sortdesc'] = isset($_POST['sfsortdesc']); $sfdisplay['editor']['toolbar'] = isset($_POST['sftoolbar']); sp_update_option('sfcontrols', $sfcontrols); sp_update_option('sfdisplay', $sfdisplay); do_action('sph_option_display_save'); return $mess; }
function sp_cron_generate_stats() { $counts = sp_get_stats_counts(); sp_update_option('spForumStats', $counts); $stats = sp_get_membership_stats(); sp_update_option('spMembershipStats', $stats); $spControls = sp_get_option('sfcontrols'); $topPosters = sp_get_top_poster_stats((int) $spControls['showtopcount']); sp_update_option('spPosterStats', $topPosters); $mods = sp_get_moderator_stats(); sp_update_option('spModStats', $mods); $admins = sp_get_admin_stats(); sp_update_option('spAdminStats', $admins); do_action('sph_stats_cron_run'); }