<commit_before><?php defined('BASEPATH') OR exit('No direct script access allowed');

/**
 * @author <NAME> <<EMAIL>>, 2013
 * @license The MIT License, http://opensource.org/licenses/MIT
 */

class Welcome_controller extends Base_Controller {

    public function __construct() {

        parent::__construct();

        $this->lang->load('welcome');

        $this->registry->set('nav', 'home');
    }

    public function index() {

        // This is just a demo page, code is done in ad-hoc manner.

        $yes = '<span style="color: green;">Yes</span>';
        $no  = '<span style="color: red;">No</span>';

        // Collecting diagnostics data.

        $writable_folders = array(

            'platform/writable/' =>
                array(
                    'path' => WRITABLEPATH,
                    'is_writable' => NULL
                ),
            'platform/upload/' =>
                array(
                    'path' => PLATFORM_UPLOAD_PATH,
                    'is_writable' => NULL
                ),
            'www/upload/' =>
                array(
                    'path' => PUBLIC_UPLOAD_PATH,
                    'is_writable' => NULL
                ),
            'www/cache/' =>
                array(
                    'path' => PUBLIC_CACHE_PATH,
                    'is_writable' => NULL
                ),
        );

        foreach ($writable_folders as $key => $folder) {

            $writable_folders[$key]['is_writable'] = is_really_writable($folder['path']);
        }

        // Diagnostics data decoration.

        $diagnostics = array();

        //----------------------------------------------------------------------

        $diagnostics[] = '<strong>Writable folders check:</strong>';

        foreach ($writable_folders as $key => $folder) {

            if ($writable_folders[$key]['is_writable']) {

                $diagnostics[] = "$key - <span style=\"color: green\">writable</span>";

            } else {

                $diagnostics[] = "$key - <span style=\"color: red\">make it writable</span>";
            }
        }

        //----------------------------------------------------------------------

        $diagnostics[] = '<br /><strong>Mailer:</strong>';

        $mailer_enabled = (bool) $this->settings->get('mailer_enabled');

        if ($mailer_enabled) {

            $diagnostics[] = 'Mailer service - <span style="color: green">enabled</span>';

        } else {

            $diagnostics[] = 'Mailer service - <span style="color: red">disabled. Check $config[\'mailer_enabled\'] option within platform/core/common/config/config_site.php. Check also the mailer settings within platform/core/common/config/email.php.</span>';
        }

        //----------------------------------------------------------------------

        $diagnostics[] = '<br /><strong>UTF-8 support:</strong>';

        $diagnostics[] = 'IS_UTF8_CHARSET - '.(IS_UTF8_CHARSET ? $yes : $no);
        $diagnostics[] = 'MBSTRING_INSTALLED - '.(MBSTRING_INSTALLED ? $yes : $no);
        $diagnostics[] = 'ICONV_INSTALLED - '.(ICONV_INSTALLED ? $yes : $no);
        $diagnostics[] = 'PCRE_UTF8_INSTALLED - '.(PCRE_UTF8_INSTALLED ? $yes : $no);
        $diagnostics[] = 'INTL_INSTALLED (optional) - '.(INTL_INSTALLED ? $yes : $no);

        //----------------------------------------------------------------------

        $diagnostics[] = '<br /><strong>Cryptography support:</strong>';

        $diagnostics[] = '\'openssl\' installed - '.(extension_loaded('openssl') ? $yes : $no);
        $diagnostics[] = 'or \'mcrypt\' installed - '.(defined('MCRYPT_DEV_URANDOM') ? $yes : $no);

        $random_bytes = $no;

        if (function_exists('random_bytes')) {

            try {
                $test = random_bytes(1);
                $random_bytes = $yes;
            }
            catch (Exception $e) {
                $random_bytes = '<span style="color: red;">'.$e->getMessage().'</span>';
            }
        }

        $diagnostics[] = 'random_bytes() - '.$random_bytes;

        //----------------------------------------------------------------------

        $diagnostics[] = '<br /><strong>Graphics:</strong>';

        $gd_installed = extension_loaded('gd');

        $gd_version = null;

        if ($gd_installed) {

            $gd_info = gd_info();<commit_msg>Don't check whether mcrypt exists as of PHP 7.1. Signed-off-by:<NAME> <<EMAIL>><commit_after><?php defined('BASEPATH') OR exit('No direct script access allowed');

/**
 * @author <NAME> <<EMAIL>>, 2013
 * @license The MIT License, http://opensource.org/licenses/MIT
 */

class Welcome_controller extends Base_Controller {

    public function __construct() {

        parent::__construct();

        $this->lang->load('welcome');

        $this->registry->set('nav', 'home');
    }

    public function index() {

        // This is just a demo page, code is done in ad-hoc manner.

        $yes = '<span style="color: green;">Yes</span>';
        $no  = '<span style="color: red;">No</span>';

        // Collecting diagnostics data.

        $writable_folders = array(

            'platform/writable/' =>
                array(
                    'path' => WRITABLEPATH,
                    'is_writable' => NULL
                ),
            'platform/upload/' =>
                array(
                    'path' => PLATFORM_UPLOAD_PATH,
                    'is_writable' => NULL
                ),
            'www/upload/' =>
                array(
                    'path' => PUBLIC_UPLOAD_PATH,
                    'is_writable' => NULL
                ),
            'www/cache/' =>
                array(
                    'path' => PUBLIC_CACHE_PATH,
                    'is_writable' => NULL
                ),
        );

        foreach ($writable_folders as $key => $folder) {

            $writable_folders[$key]['is_writable'] = is_really_writable($folder['path']);
        }

        // Diagnostics data decoration.

        $diagnostics = array();

        //----------------------------------------------------------------------

        $diagnostics[] = '<strong>Writable folders check:</strong>';

        foreach ($writable_folders as $key => $folder) {

            if ($writable_folders[$key]['is_writable']) {

                $diagnostics[] = "$key - <span style=\"color: green\">writable</span>";

            } else {

                $diagnostics[] = "$key - <span style=\"color: red\">make it writable</span>";
            }
        }

        //----------------------------------------------------------------------

        $diagnostics[] = '<br /><strong>Mailer:</strong>';

        $mailer_enabled = (bool) $this->settings->get('mailer_enabled');

        if ($mailer_enabled) {

            $diagnostics[] = 'Mailer service - <span style="color: green">enabled</span>';

        } else {

            $diagnostics[] = 'Mailer service - <span style="color: red">disabled. Check $config[\'mailer_enabled\'] option within platform/core/common/config/config_site.php. Check also the mailer settings within platform/core/common/config/email.php.</span>';
        }

        //----------------------------------------------------------------------

        $diagnostics[] = '<br /><strong>UTF-8 support:</strong>';

        $diagnostics[] = 'IS_UTF8_CHARSET - '.(IS_UTF8_CHARSET ? $yes : $no);
        $diagnostics[] = 'MBSTRING_INSTALLED - '.(MBSTRING_INSTALLED ? $yes : $no);
        $diagnostics[] = 'ICONV_INSTALLED - '.(ICONV_INSTALLED ? $yes : $no);
        $diagnostics[] = 'PCRE_UTF8_INSTALLED - '.(PCRE_UTF8_INSTALLED ? $yes : $no);
        $diagnostics[] = 'INTL_INSTALLED (optional) - '.(INTL_INSTALLED ? $yes : $no);

        //----------------------------------------------------------------------

        $diagnostics[] = '<br /><strong>Cryptography support:</strong>';

        $diagnostics[] = '\'openssl\' installed - '.(extension_loaded('openssl') ? $yes : $no);

        if (version_compare(PHP_VERSION, '7.1.0-alpha', '<')) {
            $diagnostics[] = 'or \'mcrypt\' installed - '.(defined('MCRYPT_DEV_URANDOM') ? $yes : $no);
        }

        $random_bytes = $no;

        if (function_exists('random_bytes')) {

            try {
                $test = random_bytes(1);
                $random_bytes = $yes;
            }
            catch (Exception $e) {
                $random_bytes = '<span style="color: red;">'.$e->getMessage().'</span>';
            }
        }

        $diagnostics[] = 'random_bytes() - '.$random_bytes;

        //----------------------------------------------------------------------

        $diagnostics[] = '<br /><strong>Graphics:</strong>';

        $gd_installed = extension_loaded('gd');

        $gd_version = null;

        if ($gd_installed) {

            $gd_info = gd_info();
{'fraction_non_alphanumeric': 0.23081283301213015, 'fraction_numerical': 0.0028341457884593583, 'mean_word_length': 1.4984423676012462, 'pattern_counts': {'":': 0, '<': 71, '<?xml version=': 0, '>': 110, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5329493', 'n_tokens_mistral': 2499, 'n_tokens_neox': 2310, 'n_words': 464}