Esempio n. 1
0
/**
 * Shutdown function: save HIT and update session!
 *
 * This is registered in _main.inc.php with register_shutdown_function()
 * This is called by PHP at the end of the script.
 *
 * NOTE: before PHP 4.1 nothing can be echoed here any more, but the minimum PHP requirement for b2evo is PHP 4.3
 */
function shutdown()
{
    /**
     * @var Hit
     */
    global $Hit;
    /**
     * @var Session
     */
    global $Session;
    global $Settings;
    global $Debuglog;
    global $Timer;
    global $shutdown_count_item_views;
    // Try forking a background process and let the parent return as fast as possbile.
    if (is_callable('pcntl_fork') && function_exists('posix_kill') && defined('STDIN')) {
        if ($pid = pcntl_fork()) {
            return;
        }
        // Parent
        function shutdown_kill()
        {
            posix_kill(posix_getpid(), SIGHUP);
        }
        if (ob_get_level()) {
            // Discard the output buffer and close
            ob_end_clean();
        }
        fclose(STDIN);
        // Close all of the standard
        fclose(STDOUT);
        // file descriptors as we
        fclose(STDERR);
        // are running as a daemon.
        register_shutdown_function('shutdown_kill');
        if (posix_setsid() < 0) {
            return;
        }
        if ($pid = pcntl_fork()) {
            return;
        }
        // Parent
        // Now running as a daemon. This process will even survive
        // an apachectl stop.
    }
    $Timer->resume('shutdown');
    // echo '*** SHUTDOWN FUNC KICKING IN ***';
    // fp> do we need special processing if we are in CLI mode?  probably earlier actually
    // if( ! $is_cli )
    // Note: it might be useful at some point to do special processing if the script has been aborted or has timed out
    // connection_aborted()
    // connection_status()
    if (!empty($shutdown_count_item_views)) {
        // Increment view counts for Items:
        $ItemCache =& get_ItemCache();
        foreach ($shutdown_count_item_views as $item_ID) {
            // asimo> Inserted the $item_ID != 0 check, because another way comes unexpected error on preview page
            if (!empty($item_ID) && ($Item = $ItemCache->get_by_ID($item_ID, false))) {
                $Item->count_view(array('allow_multiple_counts_per_page' => false));
            }
        }
    }
    // Save the current HIT:
    $Hit->log();
    // Update the SESSION:
    $Session->dbsave();
    // Get updates here instead of slowing down normal display of the dashboard
    load_funcs('dashboard/model/_dashboard.funcs.php');
    b2evonet_get_updates();
    // Auto pruning of old HITS, old SESSIONS and potentially MORE analytics data:
    if ($Settings->get('auto_prune_stats_mode') == 'page') {
        // Autopruning is requested
        load_class('sessions/model/_hitlist.class.php', 'Hitlist');
        Hitlist::dbprune();
        // will prune once per day, according to Settings
    }
    // Calling debug_info() here will produce complete data but it will be after </html> hence invalid.
    // Then again, it's for debug only, so it shouldn't matter that much.
    debug_info();
    // Update the SESSION again, at the very end:
    // (e.g. "Debuglogs" may have been removed in debug_info())
    $Session->dbsave();
    $Timer->pause('shutdown');
}
Esempio n. 2
0
        echo $message;
        echo '</div>';
    }
    echo '</div>';
}
$facilitate_exploits = '<p>' . T_('When enabled, this feature is known to facilitate hacking exploits in any PHP application.') . "</p>\n<p>" . T_('b2evolution includes additional measures in order not to be affected by this. However, for maximum security, we still recommend disabling this PHP feature.') . "</p>\n";
$change_ini = '<p>' . T_('If possible, change this setting to <code>%s</code> in your php.ini or ask your hosting provider about it.') . '</p>';
echo '<h2 class="page-title">' . T_('System status') . '</h2>';
// Get system stats to display:
$system_stats = get_system_stats();
// Note: hopefully, the update swill have been downloaded in the shutdown function of a previous page (including the login screen)
// However if we have outdated info, we will load updates here.
load_funcs('dashboard/model/_dashboard.funcs.php');
// Let's clear any remaining messages that should already have been displayed before...
$Messages->clear();
if (b2evonet_get_updates(true) !== NULL) {
    // Updates are allowed, display them:
    // Display info & error messages
    $Messages->display();
    /**
     * @var AbstractSettings
     */
    global $global_Cache;
    $version_status_msg = $global_Cache->get('version_status_msg');
    if (!empty($version_status_msg)) {
        // We have managed to get updates (right now or in the past):
        $msg = '<p>' . $version_status_msg . '</p>';
        $extra_msg = $global_Cache->get('extra_msg');
        if (!empty($extra_msg)) {
            $msg .= '<p>' . $extra_msg . '</p>';
        }
Esempio n. 3
0
/*
 * Administrative tasks
 */
if ($current_User->check_perm('options', 'edit')) {
    // We have some serious admin privilege:
    // Begin payload block:
    $AdminUI->disp_payload_begin();
    echo '<table class="browse" cellspacing="0" cellpadding="0" border="0"><tr><td>';
    $block_item_Widget =& new Widget('block_item');
    $block_item_Widget->title = T_('Updates from b2evolution.net');
    $block_item_Widget->disp_template_replaced('block_start');
    // EXPERIMENTAL
    load_funcs('dashboard/model/_dashboard.funcs.php');
    // Let's clear any remaining messages that should already have been displayed before...
    $Messages->clear('all');
    b2evonet_get_updates();
    // Display info & error messages
    echo $Messages->display(NULL, NULL, false, 'all', NULL, NULL, 'action_messages');
    /**
     * @var AbstractSettings
     */
    global $global_Cache;
    $updates_array = $global_Cache->get('evonet_updates');
    if (!empty($updates_array)) {
        // We have managed to get updates (right now or in the past):
        echo '<p>' . $updates_array['version_status_msg'] . '</p>';
        if (!empty($updates_array['extra_msg'])) {
            echo '<p>' . $updates_array['extra_msg'] . '</p>';
        }
    }
    $block_item_Widget->disp_template_replaced('block_end');
Esempio n. 4
0
     $chart_data[] = array('title' => T_('Messages'), 'value' => get_table_count('T_messaging__message'), 'type' => 'number');
     $stat_item_Widget = new Widget('block_item');
     $stat_item_Widget->title = T_('System metrics');
     $stat_item_Widget->disp_template_replaced('block_start');
     display_charts($chart_data);
     $stat_item_Widget->disp_template_raw('block_end');
 }
 //---- END OF - System stats ----//
 $block_item_Widget = new Widget('block_item');
 $block_item_Widget->title = T_('Updates from b2evolution.net');
 $block_item_Widget->disp_template_replaced('block_start');
 // Note: hopefully, the updates will have been downloaded in the shutdown function of a previous page (including the login screen)
 // However if we have outdated info, we will load updates here.
 // Let's clear any remaining messages that should already have been displayed before...
 $Messages->clear();
 if (b2evonet_get_updates() !== NULL) {
     // Updates are allowed, display them:
     // Display info & error messages
     $Messages->display();
     $version_status_msg = $global_Cache->get('version_status_msg');
     if (!empty($version_status_msg)) {
         // We have managed to get updates (right now or in the past):
         echo '<p>' . $version_status_msg . '</p>';
         $extra_msg = $global_Cache->get('extra_msg');
         if (!empty($extra_msg)) {
             echo '<p>' . $extra_msg . '</p>';
         }
     }
     $block_item_Widget->disp_template_replaced('block_end');
     /*
      * DashboardAdminMain to be added here (anyone?)
Esempio n. 5
0
 * Display payload:
 */
switch ($action) {
    case 'start':
    default:
        // STEP 1: Check for updates.
        if ($tab == '') {
            $block_item_Widget = new Widget('block_item');
            $block_item_Widget->title = T_('Updates from b2evolution.net') . get_manual_link('auto-upgrade');
            $block_item_Widget->disp_template_replaced('block_start');
            // Note: hopefully, the update will have been downloaded in the shutdown function of a previous page (including the login screen)
            // However if we have outdated info, we will load updates here.
            load_funcs('dashboard/model/_dashboard.funcs.php');
            // Let's clear any remaining messages that should already have been displayed before...
            $Messages->clear();
            b2evonet_get_updates(true);
            // Display info & error messages
            echo $Messages->display(NULL, NULL, false, 'action_messages');
            /**
             * @var AbstractSettings
             */
            global $global_Cache;
            // Display the current version info for now. We may remove this in the future.
            $version_status_msg = $global_Cache->get('version_status_msg');
            if (!empty($version_status_msg)) {
                // We have managed to get updates (right now or in the past):
                echo '<p>' . $version_status_msg . '</p>';
                $extra_msg = $global_Cache->get('extra_msg');
                if (!empty($extra_msg)) {
                    echo '<p>' . $extra_msg . '</p>';
                }