/**
 * Main driver for running system check 
 * @since 1.2.4
 * @param $registry
 * @param $mode ('log', 'return') 
 * @return array
 *
 * Note: This is English text only. Can be call before database and languges are loaded
 */
function run_system_check($registry, $mode = 'log')
{
    $mlog = $counts = array();
    $mlog[] = check_install_directory($registry);
    $mlog = array_merge($mlog, check_file_permissions($registry));
    $mlog = array_merge($mlog, check_php_configuraion($registry));
    $mlog = array_merge($mlog, check_server_configuration($registry));
    $counts['error_count'] = $counts['warning_count'] = $counts['notice_count'] = 0;
    foreach ($mlog as $message) {
        if ($message['type'] == 'E') {
            if ($mode == 'log') {
                //only save errors to the log
                $error = new AError($message['body']);
                $error->toLog()->toDebug();
                $registry->get('messages')->saveError($message['title'], $message['body']);
            }
            $counts['error_count']++;
        } else {
            if ($message['type'] == 'W') {
                if ($mode == 'log') {
                    $registry->get('messages')->saveWarning($message['title'], $message['body']);
                }
                $counts['warning_count']++;
            } else {
                if ($message['type'] == 'N') {
                    if ($mode == 'log') {
                        $registry->get('messages')->saveNotice($message['title'], $message['body']);
                    }
                    $counts['notice_count']++;
                }
            }
        }
    }
    return array($mlog, $counts);
}
Exemplo n.º 2
0
/**
 * Main driver for running system check 
 * @since 1.2.4
 * @param  Registry $registry
 * @param string $mode ('log', 'return')
 * @return array
 *
 * Note: This is English text only. Can be call before database and languages are loaded
 */
function run_system_check($registry, $mode = 'log')
{
    $mlog = $counts = array();
    //run anyway
    $mlog[] = check_install_directory();
    if (IS_ADMIN === true && (!$registry->get('config')->get('config_system_check') || $registry->get('config')->get('config_system_check') == 1) || IS_ADMIN !== true && (!$registry->get('config')->get('config_system_check') || $registry->get('config')->get('config_system_check') == 2)) {
        $mlog = array_merge($mlog, check_file_permissions($registry));
        $mlog = array_merge($mlog, check_php_configuraion());
        $mlog = array_merge($mlog, check_server_configuration($registry));
        $mlog = array_merge($mlog, check_order_statuses($registry));
        $mlog = array_merge($mlog, check_web_access());
    }
    $counts['error_count'] = $counts['warning_count'] = $counts['notice_count'] = 0;
    foreach ($mlog as $message) {
        if ($message['type'] == 'E') {
            if ($mode == 'log') {
                //only save errors to the log
                $error = new AError($message['body']);
                $error->toLog()->toDebug();
                $registry->get('messages')->saveError($message['title'], $message['body']);
            }
            $counts['error_count']++;
        } else {
            if ($message['type'] == 'W') {
                if ($mode == 'log') {
                    $registry->get('messages')->saveWarning($message['title'], $message['body']);
                }
                $counts['warning_count']++;
            } else {
                if ($message['type'] == 'N') {
                    if ($mode == 'log') {
                        $registry->get('messages')->saveNotice($message['title'], $message['body']);
                    }
                    $counts['notice_count']++;
                }
            }
        }
    }
    return array($mlog, $counts);
}