Proyectos de Subversion Moodle

Rev

Rev 11 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 11 Rev 1441
Línea 194... Línea 194...
194
    }
194
    }
195
    echo('Fatal error: $CFG->wwwroot is not configured! Exiting.'."\n");
195
    echo('Fatal error: $CFG->wwwroot is not configured! Exiting.'."\n");
196
    exit(1);
196
    exit(1);
197
}
197
}
Línea -... Línea 198...
-
 
198
 
-
 
199
// The router configuration is mandatory.
-
 
200
$CFG->routerconfigured = !empty($CFG->routerconfigured);
198
 
201
 
199
// Make sure there is some database table prefix.
202
// Make sure there is some database table prefix.
200
if (!isset($CFG->prefix)) {
203
if (!isset($CFG->prefix)) {
201
    $CFG->prefix = '';
204
    $CFG->prefix = '';
Línea 308... Línea 311...
308
if (!defined('CACHE_DISABLE_ALL')) {
311
if (!defined('CACHE_DISABLE_ALL')) {
309
    define('CACHE_DISABLE_ALL', false);
312
    define('CACHE_DISABLE_ALL', false);
310
}
313
}
Línea 311... Línea 314...
311
 
314
 
312
// When set to true MUC (Moodle caching) will not use any of the defined or default stores.
315
// When set to true MUC (Moodle caching) will not use any of the defined or default stores.
313
// The Cache API will continue to function however this will force the use of the cachestore_dummy so all requests
316
// The Cache API will continue to function however this will force the use of the dummy_cachestore so all requests
314
// will be interacting with a static property and will never go to the proper cache stores.
317
// will be interacting with a static property and will never go to the proper cache stores.
315
// Useful if you need to avoid the stores for one reason or another.
318
// Useful if you need to avoid the stores for one reason or another.
316
if (!defined('CACHE_DISABLE_STORES')) {
319
if (!defined('CACHE_DISABLE_STORES')) {
317
    define('CACHE_DISABLE_STORES', false);
320
    define('CACHE_DISABLE_STORES', false);
Línea 425... Línea 428...
425
if (isset($CFG->debug)) {
428
if (isset($CFG->debug)) {
426
    $CFG->debug = (int)$CFG->debug;
429
    $CFG->debug = (int)$CFG->debug;
427
} else {
430
} else {
428
    $CFG->debug = 0;
431
    $CFG->debug = 0;
429
}
432
}
430
$CFG->debugdeveloper = (($CFG->debug & (E_ALL | E_STRICT)) === (E_ALL | E_STRICT)); // DEBUG_DEVELOPER is not available yet.
433
$CFG->debugdeveloper = (($CFG->debug & E_ALL) === E_ALL); // DEBUG_DEVELOPER is not available yet.
Línea 431... Línea 434...
431
 
434
 
432
if (!defined('MOODLE_INTERNAL')) { // Necessary because cli installer has to define it earlier.
435
if (!defined('MOODLE_INTERNAL')) { // Necessary because cli installer has to define it earlier.
433
    /** Used by library scripts to check they are being called by Moodle. */
436
    /** Used by library scripts to check they are being called by Moodle. */
434
    define('MOODLE_INTERNAL', true);
437
    define('MOODLE_INTERNAL', true);
Línea 435... Línea 438...
435
}
438
}
436
 
439
 
Línea 437... Línea -...
437
// core_component can be used in any scripts, it does not need anything else.
-
 
438
require_once($CFG->libdir .'/classes/component.php');
-
 
439
 
-
 
440
// special support for highly optimised scripts that do not need libraries and DB connection
-
 
441
if (defined('ABORT_AFTER_CONFIG')) {
-
 
442
    if (!defined('ABORT_AFTER_CONFIG_CANCEL')) {
-
 
443
        // hide debugging if not enabled in config.php - we do not want to disclose sensitive info
-
 
444
        error_reporting($CFG->debug);
-
 
445
        if (NO_DEBUG_DISPLAY) {
-
 
446
            // Some parts of Moodle cannot display errors and debug at all.
-
 
447
            ini_set('display_errors', '0');
-
 
448
            ini_set('log_errors', '1');
-
 
449
        } else if (empty($CFG->debugdisplay)) {
-
 
450
            ini_set('display_errors', '0');
-
 
451
            ini_set('log_errors', '1');
-
 
452
        } else {
-
 
453
            ini_set('display_errors', '1');
-
 
454
        }
-
 
455
        require_once("$CFG->dirroot/lib/configonlylib.php");
-
 
456
        return;
-
 
457
    }
-
 
458
}
-
 
459
 
-
 
460
// Early profiling start, based exclusively on config.php $CFG settings
-
 
461
if (!empty($CFG->earlyprofilingenabled)) {
-
 
462
    require_once($CFG->libdir . '/xhprof/xhprof_moodle.php');
-
 
463
    profiling_start();
440
// The core_component class can be used in any scripts, it does not need anything else.
464
}
441
require_once($CFG->libdir .'/classes/component.php');
465
 
442
 
466
/**
443
/**
467
 * Database connection. Used for all access to the database.
444
 * Database connection. Used for all access to the database.
Línea 569... Línea 546...
569
global $SCRIPT;
546
global $SCRIPT;
Línea 570... Línea 547...
570
 
547
 
571
// The httpswwwroot has been deprecated, we keep it as an alias for backwards compatibility with plugins only.
548
// The httpswwwroot has been deprecated, we keep it as an alias for backwards compatibility with plugins only.
Línea 572... Línea 549...
572
$CFG->httpswwwroot = $CFG->wwwroot;
549
$CFG->httpswwwroot = $CFG->wwwroot;
573
 
-
 
574
require_once($CFG->libdir .'/setuplib.php');        // Functions that MUST be loaded first
550
 
575
 
551
// We have to call this always before starting session because it discards headers!
-
 
552
if (NO_OUTPUT_BUFFERING) {
-
 
553
    // Try to disable all output buffering and purge all headers.
-
 
554
    $olddebug = error_reporting(0);
-
 
555
 
-
 
556
    // Disable compression, it would prevent closing of buffers.
-
 
557
    if ($outputcompression = ini_get('zlib.output_compression')) {
-
 
558
        switch(strtolower($outputcompression)) {
-
 
559
            case 'on':
-
 
560
            case '1':
-
 
561
                ini_set('zlib.output_compression', 'Off');
-
 
562
                break;
-
 
563
        }
-
 
564
    }
-
 
565
 
-
 
566
    // Try to flush everything all the time.
-
 
567
    ob_implicit_flush(true);
-
 
568
 
-
 
569
    // Close all buffers if possible and discard any existing output.
-
 
570
    // This can actually work around some whitespace problems in config.php.
-
 
571
    while (ob_get_level()) {
-
 
572
        if (!ob_end_clean()) {
-
 
573
            // Prevent infinite loop when buffer can not be closed.
-
 
574
            break;
-
 
575
        }
-
 
576
    }
576
if (NO_OUTPUT_BUFFERING) {
577
 
-
 
578
    // Disable any other output handlers.
-
 
579
    ini_set('output_handler', '');
-
 
580
 
-
 
581
    error_reporting($olddebug);
-
 
582
 
-
 
583
    // Disable buffering in nginx.
-
 
584
    header('X-Accel-Buffering: no');
-
 
585
}
-
 
586
 
-
 
587
// Point pear include path to moodles lib/pear so that includes and requires will search there for files before anywhere else
-
 
588
// the problem is that we need specific version of quickforms and hacked excel files :-(.
-
 
589
ini_set('include_path', $CFG->libdir . '/pear' . PATH_SEPARATOR . ini_get('include_path'));
-
 
590
 
-
 
591
// Register our classloader.
-
 
592
\core\component::register_autoloader();
-
 
593
 
-
 
594
// Early profiling start, based exclusively on config.php $CFG settings
-
 
595
if (!empty($CFG->earlyprofilingenabled) && !defined('ABORT_AFTER_CONFIG_CANCEL')) {
577
    // we have to call this always before starting session because it discards headers!
596
    require_once($CFG->libdir . '/xhprof/xhprof_moodle.php');
Línea -... Línea 597...
-
 
597
    profiling_start();
-
 
598
}
-
 
599
 
-
 
600
// Special support for highly optimised scripts that do not need libraries and DB connection.
-
 
601
if (defined('ABORT_AFTER_CONFIG')) {
-
 
602
    if (!defined('ABORT_AFTER_CONFIG_CANCEL')) {
-
 
603
        // Hide debugging if not enabled in config.php - we do not want to disclose sensitive info.
-
 
604
        error_reporting($CFG->debug);
-
 
605
        if (NO_DEBUG_DISPLAY) {
-
 
606
            // Some parts of Moodle cannot display errors and debug at all.
-
 
607
            ini_set('display_errors', '0');
-
 
608
            ini_set('log_errors', '1');
-
 
609
        } else if (empty($CFG->debugdisplay)) {
-
 
610
            ini_set('display_errors', '0');
-
 
611
            ini_set('log_errors', '1');
-
 
612
        } else {
-
 
613
            ini_set('display_errors', '1');
-
 
614
        }
-
 
615
        require_once("$CFG->dirroot/lib/configonlylib.php");
-
 
616
        return;
-
 
617
    }
-
 
618
}
-
 
619
 
-
 
620
require_once($CFG->libdir .'/setuplib.php');        // Functions that MUST be loaded first.
-
 
621
 
-
 
622
// Load up standard libraries.
-
 
623
require_once($CFG->libdir .'/filterlib.php');       // Functions for filtering test as it is output.
-
 
624
require_once($CFG->libdir .'/ajax/ajaxlib.php');    // Functions for managing our use of JavaScript and YUI.
-
 
625
require_once($CFG->libdir .'/weblib.php');          // Functions relating to HTTP and content.
-
 
626
require_once($CFG->libdir .'/outputlib.php');       // Functions for generating output.
-
 
627
require_once($CFG->libdir .'/navigationlib.php');   // Class for generating Navigation structure.
-
 
628
require_once($CFG->libdir .'/dmllib.php');          // Database access.
-
 
629
require_once($CFG->libdir .'/datalib.php');         // Legacy lib with a big-mix of functions..
-
 
630
require_once($CFG->libdir .'/accesslib.php');       // Access control functions.
-
 
631
require_once($CFG->libdir .'/deprecatedlib.php');   // Deprecated functions included for backward compatibility.
-
 
632
require_once($CFG->libdir .'/moodlelib.php');       // Other general-purpose functions.
-
 
633
require_once($CFG->libdir .'/enrollib.php');        // Enrolment related functions.
-
 
634
require_once($CFG->libdir .'/pagelib.php');         // Library that defines the moodle_page class, used for $PAGE.
-
 
635
require_once($CFG->libdir .'/blocklib.php');        // Library for controlling blocks.
-
 
636
require_once($CFG->libdir .'/grouplib.php');        // Groups functions.
-
 
637
require_once($CFG->libdir .'/sessionlib.php');      // All session and cookie related stuff.
-
 
638
require_once($CFG->libdir .'/editorlib.php');       // All text editor related functions and classes.
578
    disable_output_buffering();
639
require_once($CFG->libdir .'/messagelib.php');      // Messagelib functions.
579
}
640
require_once($CFG->libdir .'/modinfolib.php');      // Cached information on course-module instances.
Línea 580... Línea 641...
580
 
641
 
581
// Increase memory limits if possible
642
// Increase memory limits if possible.
Línea 588... Línea 649...
588
$OUTPUT = new bootstrap_renderer();
649
$OUTPUT = new bootstrap_renderer();
Línea 589... Línea 650...
589
 
650
 
590
// Set handler for uncaught exceptions - equivalent to throw new \moodle_exception() call.
651
// Set handler for uncaught exceptions - equivalent to throw new \moodle_exception() call.
591
if (!PHPUNIT_TEST or PHPUNIT_UTIL) {
652
if (!PHPUNIT_TEST or PHPUNIT_UTIL) {
592
    set_exception_handler('default_exception_handler');
653
    set_exception_handler('default_exception_handler');
593
    set_error_handler('default_error_handler', E_ALL | E_STRICT);
654
    set_error_handler('default_error_handler', E_ALL);
Línea 594... Línea 655...
594
}
655
}
595
 
656
 
596
// Acceptance tests needs special output to capture the errors,
657
// Acceptance tests needs special output to capture the errors,
597
// but not necessary for behat CLI command and init script.
658
// but not necessary for behat CLI command and init script.
598
if (defined('BEHAT_SITE_RUNNING') && !defined('BEHAT_TEST') && !defined('BEHAT_UTIL')) {
659
if (defined('BEHAT_SITE_RUNNING') && !defined('BEHAT_TEST') && !defined('BEHAT_UTIL')) {
599
    require_once(__DIR__ . '/behat/lib.php');
660
    require_once(__DIR__ . '/behat/lib.php');
Línea 600... Línea 661...
600
    set_error_handler('behat_error_handler', E_ALL | E_STRICT);
661
    set_error_handler('behat_error_handler', E_ALL);
601
}
662
}
602
 
663
 
603
if (defined('WS_SERVER') && WS_SERVER) {
664
if (defined('WS_SERVER') && WS_SERVER) {
Línea 604... Línea 665...
604
    require_once($CFG->dirroot . '/webservice/lib.php');
665
    require_once($CFG->dirroot . '/webservice/lib.php');
605
    set_exception_handler('early_ws_exception_handler');
666
    set_exception_handler('early_ws_exception_handler');
Línea 606... Línea 667...
606
}
667
}
607
 
668
 
608
// If there are any errors in the standard libraries we want to know!
669
// If there are any errors in the standard libraries we want to know!
609
error_reporting(E_ALL | E_STRICT);
670
error_reporting(E_ALL);
610
 
671
 
611
// Just say no to link prefetching (Moz prefetching, Google Web Accelerator, others)
672
// Just say no to link prefetching (Moz prefetching, Google Web Accelerator, others)
612
// http://www.google.com/webmasters/faq.html#prefetchblock
673
// http://www.google.com/webmasters/faq.html#prefetchblock
Línea 613... Línea -...
613
if (!empty($_SERVER['HTTP_X_moz']) && $_SERVER['HTTP_X_moz'] === 'prefetch'){
-
 
614
    header($_SERVER['SERVER_PROTOCOL'] . ' 404 Prefetch Forbidden');
-
 
615
    echo('Prefetch request forbidden.');
-
 
616
    exit(1);
-
 
617
}
-
 
618
 
-
 
619
//point pear include path to moodles lib/pear so that includes and requires will search there for files before anywhere else
-
 
620
//the problem is that we need specific version of quickforms and hacked excel files :-(
-
 
621
ini_set('include_path', $CFG->libdir.'/pear' . PATH_SEPARATOR . ini_get('include_path'));
-
 
622
 
-
 
623
// Register our classloader, in theory somebody might want to replace it to load other hacked core classes.
-
 
624
if (defined('COMPONENT_CLASSLOADER')) {
674
if (!empty($_SERVER['HTTP_X_moz']) && $_SERVER['HTTP_X_moz'] === 'prefetch'){
625
    spl_autoload_register(COMPONENT_CLASSLOADER);
675
    header($_SERVER['SERVER_PROTOCOL'] . ' 404 Prefetch Forbidden');
Línea 626... Línea -...
626
} else {
-
 
627
    spl_autoload_register('core_component::classloader');
-
 
628
}
-
 
629
 
-
 
630
// Remember the default PHP timezone, we will need it later.
-
 
631
core_date::store_default_php_timezone();
-
 
632
 
-
 
633
// Load up standard libraries
-
 
634
require_once($CFG->libdir .'/filterlib.php');       // Functions for filtering test as it is output
-
 
635
require_once($CFG->libdir .'/ajax/ajaxlib.php');    // Functions for managing our use of JavaScript and YUI
-
 
636
require_once($CFG->libdir .'/weblib.php');          // Functions relating to HTTP and content
-
 
637
require_once($CFG->libdir .'/outputlib.php');       // Functions for generating output
-
 
638
require_once($CFG->libdir .'/navigationlib.php');   // Class for generating Navigation structure
-
 
639
require_once($CFG->libdir .'/dmllib.php');          // Database access
-
 
640
require_once($CFG->libdir .'/datalib.php');         // Legacy lib with a big-mix of functions.
-
 
641
require_once($CFG->libdir .'/accesslib.php');       // Access control functions
-
 
642
require_once($CFG->libdir .'/deprecatedlib.php');   // Deprecated functions included for backward compatibility
-
 
643
require_once($CFG->libdir .'/moodlelib.php');       // Other general-purpose functions
-
 
644
require_once($CFG->libdir .'/enrollib.php');        // Enrolment related functions
-
 
645
require_once($CFG->libdir .'/pagelib.php');         // Library that defines the moodle_page class, used for $PAGE
-
 
646
require_once($CFG->libdir .'/blocklib.php');        // Library for controlling blocks
-
 
647
require_once($CFG->libdir .'/grouplib.php');        // Groups functions
676
    echo('Prefetch request forbidden.');
648
require_once($CFG->libdir .'/sessionlib.php');      // All session and cookie related stuff
677
    exit(1);
Línea 649... Línea 678...
649
require_once($CFG->libdir .'/editorlib.php');       // All text editor related functions and classes
678
}
650
require_once($CFG->libdir .'/messagelib.php');      // Messagelib functions
679
 
Línea 738... Línea 767...
738
    // Keep it "as is" during installation.
767
    // Keep it "as is" during installation.
739
} else if (NO_DEBUG_DISPLAY) {
768
} else if (NO_DEBUG_DISPLAY) {
740
    // Some parts of Moodle cannot display errors and debug at all.
769
    // Some parts of Moodle cannot display errors and debug at all.
741
    ini_set('display_errors', '0');
770
    ini_set('display_errors', '0');
742
    ini_set('log_errors', '1');
771
    ini_set('log_errors', '1');
-
 
772
    ini_set('zend.exception_ignore_args', '1');
743
} else if (empty($CFG->debugdisplay)) {
773
} else if (empty($CFG->debugdisplay)) {
744
    ini_set('display_errors', '0');
774
    ini_set('display_errors', '0');
745
    ini_set('log_errors', '1');
775
    ini_set('log_errors', '1');
-
 
776
    ini_set('zend.exception_ignore_args', '1');
746
} else {
777
} else {
747
    // This is very problematic in XHTML strict mode!
778
    // This is very problematic in XHTML strict mode!
748
    ini_set('display_errors', '1');
779
    ini_set('display_errors', '1');
749
}
780
}
Línea 1128... Línea 1159...
1128
    }
1159
    }
1129
}
1160
}
Línea 1130... Línea 1161...
1130
 
1161
 
1131
// Switch to CLI maintenance mode if required, we need to do it here after all the settings are initialised.
1162
// Switch to CLI maintenance mode if required, we need to do it here after all the settings are initialised.
-
 
1163
if (isset($CFG->maintenance_later) and $CFG->maintenance_later <= time()) {
-
 
1164
 
-
 
1165
    // Because maintenance_later is triggered by any potentially real non admin user
-
 
1166
    // who just happened to be the first to load a page after the time is due, we do
-
 
1167
    // this simple workaround so add_to_config_log doesn't log it as them.
-
 
1168
    \core\session\manager::write_close();
-
 
1169
    $USER->id = 0;
1132
if (isset($CFG->maintenance_later) and $CFG->maintenance_later <= time()) {
1170
 
1133
    if (!file_exists("$CFG->dataroot/climaintenance.html")) {
1171
    if (!file_exists("$CFG->dataroot/climaintenance.html")) {
-
 
1172
        require_once("$CFG->libdir/adminlib.php");
1134
        require_once("$CFG->libdir/adminlib.php");
1173
        set_config('maintenance_enabled', 'cli mode', null, true);
1135
        enable_cli_maintenance_mode();
1174
        enable_cli_maintenance_mode();
-
 
1175
    }
1136
    }
1176
    if (isset($CFG->maintenance_later)) {
-
 
1177
        unset_config('maintenance_later', null, true);
1137
    unset_config('maintenance_later');
1178
    }
1138
    if (AJAX_SCRIPT) {
1179
    if (AJAX_SCRIPT) {
1139
        die;
1180
        die;
-
 
1181
    } else if (!CLI_SCRIPT) {
-
 
1182
        // We redirect to ourselves to reload the page to get a fresh bootstrap
1140
    } else if (!CLI_SCRIPT) {
1183
        // so that we get the maintenance page which is earlier in setup.
1141
        redirect(new moodle_url('/'));
1184
        redirect(new moodle_url($ME));
1142
    }
1185
    }
Línea 1143... Línea 1186...
1143
}
1186
}
1144
 
1187
 
Línea 1163... Línea 1206...
1163
 
1206
 
1164
// Cache any immutable config locally to avoid constant DB lookups.
1207
// Cache any immutable config locally to avoid constant DB lookups.
Línea 1165... Línea 1208...
1165
initialise_local_config_cache();
1208
initialise_local_config_cache();
1166
 
1209
 
1167
// Allow plugins to callback as soon possible after setup.php is loaded.
1210
// Allow plugins to callback as soon possible after setup.php is loaded.
1168
$pluginswithfunction = get_plugins_with_function('after_config', 'lib.php');
-
 
1169
foreach ($pluginswithfunction as $plugins) {
-
 
1170
    foreach ($plugins as $function) {
-
 
1171
        try {
-
 
1172
            $function();
1211
$afterconfighook = new \core\hook\after_config();
1173
        } catch (Throwable $e) {
-
 
1174
            debugging("Exception calling '$function'", DEBUG_DEVELOPER, $e->getTrace());
-
 
1175
        }
-