3v4l.org

run code in 300+ PHP versions simultaneously
<?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Moodle frontpage. * * @package core * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ if (!file_exists('./config.php')) { header('Location: install.php'); die; } require_once('config.php'); require_once($CFG->dirroot .'/course/lib.php'); require_once($CFG->libdir .'/filelib.php'); redirect_if_major_upgrade_required(); $urlparams = array(); if (!empty($CFG->defaulthomepage) && ($CFG->defaulthomepage == HOMEPAGE_MY) && optional_param('redirect', 1, PARAM_BOOL) === 0) { $urlparams['redirect'] = 0; } $PAGE->set_url('/', $urlparams); $PAGE->set_course($SITE); $PAGE->set_other_editing_capability('moodle/course:update'); $PAGE->set_other_editing_capability('moodle/course:manageactivities'); $PAGE->set_other_editing_capability('moodle/course:activityvisibility'); // Prevent caching of this page to stop confusion when changing page after making AJAX changes $PAGE->set_cacheable(false); if ($CFG->forcelogin) { require_login(); } else { user_accesstime_log(); } $hassiteconfig = has_capability('moodle/site:config', context_system::instance()); /// If the site is currently under maintenance, then print a message if (!empty($CFG->maintenance_enabled) and !$hassiteconfig) { print_maintenance_message(); } if ($hassiteconfig && moodle_needs_upgrading()) { redirect($CFG->wwwroot .'/'. $CFG->admin .'/index.php'); } if (get_home_page() != HOMEPAGE_SITE) { // Redirect logged-in users to My Moodle overview if required if (optional_param('setdefaulthome', false, PARAM_BOOL)) { set_user_preference('user_home_page_preference', HOMEPAGE_SITE); } else if (!empty($CFG->defaulthomepage) && ($CFG->defaulthomepage == HOMEPAGE_MY) && optional_param('redirect', 1, PARAM_BOOL) === 1) { redirect($CFG->wwwroot .'/my/'); } else if (!empty($CFG->defaulthomepage) && ($CFG->defaulthomepage == HOMEPAGE_USER)) { $PAGE->settingsnav->get('usercurrentsettings')->add(get_string('makethismyhome'), new moodle_url('/', array('setdefaulthome'=>true)), navigation_node::TYPE_SETTING); } } $eventparams = array('context' => context_course::instance(SITEID)); $event = \core\event\course_viewed::create($eventparams); $event->trigger(); /// If the hub plugin is installed then we let it take over the homepage here if (file_exists($CFG->dirroot.'/local/hub/lib.php') and get_config('local_hub', 'hubenabled')) { require_once($CFG->dirroot.'/local/hub/lib.php'); $hub = new local_hub(); $continue = $hub->display_homepage(); //display_homepage() return true if the hub home page is not displayed //mostly when search form is not displayed for not logged users if (empty($continue)) { exit; } } $PAGE->set_pagetype('site-index'); $PAGE->set_docs_path(''); $PAGE->set_pagelayout('frontpage'); $editing = $PAGE->user_is_editing(); $PAGE->set_title($SITE->fullname); $PAGE->set_heading($SITE->fullname); $courserenderer = $PAGE->get_renderer('core', 'course'); echo $OUTPUT->header(); /// Print Section or custom info $siteformatoptions = course_get_format($SITE)->get_format_options(); $modinfo = get_fast_modinfo($SITE); $modnames = get_module_types_names(); $modnamesplural = get_module_types_names(true); $modnamesused = $modinfo->get_used_module_names(); $mods = $modinfo->get_cms(); if (!empty($CFG->customfrontpageinclude)) { include($CFG->customfrontpageinclude); } else if ($siteformatoptions['numsections'] > 0) { if ($editing) { // make sure section with number 1 exists course_create_sections_if_missing($SITE, 1); // re-request modinfo in case section was created $modinfo = get_fast_modinfo($SITE); } $section = $modinfo->get_section_info(1); if (($section && (!empty($modinfo->sections[1]) or !empty($section->summary))) or $editing) { echo $OUTPUT->box_start('generalbox sitetopic'); /// If currently moving a file then show the current clipboard if (ismoving($SITE->id)) { $stractivityclipboard = strip_tags(get_string('activityclipboard', '', $USER->activitycopyname)); echo '<p><font size="2">'; echo "$stractivityclipboard&nbsp;&nbsp;(<a href=\"course/mod.php?cancelcopy=true&amp;sesskey=".sesskey()."\">". get_string('cancel') .'</a>)'; echo '</font></p>'; } $context = context_course::instance(SITEID); $summarytext = file_rewrite_pluginfile_urls($section->summary, 'pluginfile.php', $context->id, 'course', 'section', $section->id); $summaryformatoptions = new stdClass(); $summaryformatoptions->noclean = true; $summaryformatoptions->overflowdiv = true; echo format_text($summarytext, $section->summaryformat, $summaryformatoptions); if ($editing && has_capability('moodle/course:update', $context)) { $streditsummary = get_string('editsummary'); echo "<a title=\"$streditsummary\" ". " href=\"course/editsection.php?id=$section->id\"><img src=\"" . $OUTPUT->pix_url('t/edit') . "\" ". " class=\"iconsmall\" alt=\"$streditsummary\" /></a><br /><br />"; } $courserenderer = $PAGE->get_renderer('core', 'course'); echo $courserenderer->course_section_cm_list($SITE, $section); echo $courserenderer->course_section_add_cm_control($SITE, $section->section); echo $OUTPUT->box_end(); } } // Include course AJAX include_course_ajax($SITE, $modnamesused); if (isloggedin() and !isguestuser() and isset($CFG->frontpageloggedin)) { $frontpagelayout = $CFG->frontpageloggedin; } else { $frontpagelayout = $CFG->frontpage; } foreach (explode(',',$frontpagelayout) as $v) { switch ($v) { /// Display the main part of the front page. case FRONTPAGENEWS: if ($SITE->newsitems) { // Print forums only when needed require_once($CFG->dirroot .'/mod/forum/lib.php'); if (! $newsforum = forum_get_course_forum($SITE->id, 'news')) { print_error('cannotfindorcreateforum', 'forum'); } // fetch news forum context for proper filtering to happen $newsforumcm = get_coursemodule_from_instance('forum', $newsforum->id, $SITE->id, false, MUST_EXIST); $newsforumcontext = context_module::instance($newsforumcm->id, MUST_EXIST); $forumname = format_string($newsforum->name, true, array('context' => $newsforumcontext)); echo html_writer::tag('a', get_string('skipa', 'access', core_text::strtolower(strip_tags($forumname))), array('href'=>'#skipsitenews', 'class'=>'skip-block')); // wraps site news forum in div container. echo html_writer::start_tag('div', array('id'=>'site-news-forum')); if (isloggedin()) { $SESSION->fromdiscussion = $CFG->wwwroot; $subtext = ''; if (forum_is_subscribed($USER->id, $newsforum)) { if (!forum_is_forcesubscribed($newsforum)) { $subtext = get_string('unsubscribe', 'forum'); } } else { $subtext = get_string('subscribe', 'forum'); } echo $OUTPUT->heading($forumname); $suburl = new moodle_url('/mod/forum/subscribe.php', array('id' => $newsforum->id, 'sesskey' => sesskey())); echo html_writer::tag('div', html_writer::link($suburl, $subtext), array('class' => 'subscribelink')); } else { echo $OUTPUT->heading($forumname); } forum_print_latest_discussions($SITE, $newsforum, $SITE->newsitems, 'plain', 'p.modified DESC'); //end site news forum div container echo html_writer::end_tag('div'); echo html_writer::tag('span', '', array('class'=>'skip-block-to', 'id'=>'skipsitenews')); } break; case FRONTPAGEENROLLEDCOURSELIST: $mycourseshtml = $courserenderer->frontpage_my_courses(); if (!empty($mycourseshtml)) { echo html_writer::tag('a', get_string('skipa', 'access', core_text::strtolower(get_string('mycourses'))), array('href'=>'#skipmycourses', 'class'=>'skip-block')); //wrap frontpage course list in div container echo html_writer::start_tag('div', array('id'=>'frontpage-course-list')); echo $OUTPUT->heading(get_string('mycourses')); echo $mycourseshtml; //end frontpage course list div container echo html_writer::end_tag('div'); echo html_writer::tag('span', '', array('class'=>'skip-block-to', 'id'=>'skipmycourses')); break; } // No "break" here. If there are no enrolled courses - continue to 'Available courses'. case FRONTPAGEALLCOURSELIST: $availablecourseshtml = $courserenderer->frontpage_available_courses(); if (!empty($availablecourseshtml)) { echo html_writer::tag('a', get_string('skipa', 'access', core_text::strtolower(get_string('availablecourses'))), array('href'=>'#skipavailablecourses', 'class'=>'skip-block')); //wrap frontpage course list in div container echo html_writer::start_tag('div', array('id'=>'frontpage-course-list')); echo $OUTPUT->heading(get_string('availablecourses')); echo $availablecourseshtml; //end frontpage course list div container echo html_writer::end_tag('div'); echo html_writer::tag('span', '', array('class'=>'skip-block-to', 'id'=>'skipavailablecourses')); } break; case FRONTPAGECATEGORYNAMES: echo html_writer::tag('a', get_string('skipa', 'access', core_text::strtolower(get_string('categories'))), array('href'=>'#skipcategories', 'class'=>'skip-block')); //wrap frontpage category names in div container echo html_writer::start_tag('div', array('id'=>'frontpage-category-names')); echo $OUTPUT->heading(get_string('categories')); echo $courserenderer->frontpage_categories_list(); //end frontpage category names div container echo html_writer::end_tag('div'); echo html_writer::tag('span', '', array('class'=>'skip-block-to', 'id'=>'skipcategories')); break; case FRONTPAGECATEGORYCOMBO: echo html_writer::tag('a', get_string('skipa', 'access', core_text::strtolower(get_string('courses'))), array('href'=>'#skipcourses', 'class'=>'skip-block')); //wrap frontpage category combo in div container echo html_writer::start_tag('div', array('id'=>'frontpage-category-combo')); echo $OUTPUT->heading(get_string('courses')); echo $courserenderer->frontpage_combo_list(); //end frontpage category combo div container echo html_writer::end_tag('div'); echo html_writer::tag('span', '', array('class'=>'skip-block-to', 'id'=>'skipcourses')); break; case FRONTPAGECOURSESEARCH: echo $OUTPUT->box($courserenderer->course_search_form('', 'short'), 'mdl-align'); break; } echo '<br />'; } if ($editing && has_capability('moodle/course:create', context_system::instance())) { echo $courserenderer->add_new_course_button(); } echo $OUTPUT->footer();

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0110.01117.00
8.3.50.0100.00822.85
8.3.40.0090.01218.79
8.3.30.0000.01419.23
8.3.20.0000.00820.46
8.3.10.0050.00323.48
8.3.00.0050.00319.38
8.2.180.0130.00316.63
8.2.170.0090.00622.96
8.2.160.0100.00320.72
8.2.150.0050.00324.18
8.2.140.0030.00624.66
8.2.130.0130.00626.16
8.2.120.0000.00820.90
8.2.110.0050.00522.19
8.2.100.0110.00018.29
8.2.90.0040.00419.54
8.2.80.0060.00317.97
8.2.70.0060.00318.00
8.2.60.0060.00318.18
8.2.50.0060.00318.07
8.2.40.0040.00418.53
8.2.30.0000.00818.17
8.2.20.0030.00517.85
8.2.10.0030.00618.36
8.2.00.0040.00418.07
8.1.280.0040.01125.92
8.1.270.0000.00922.46
8.1.260.0090.00026.35
8.1.250.0040.00428.09
8.1.240.0100.00023.83
8.1.230.0040.00719.40
8.1.220.0000.00818.01
8.1.210.0080.00018.77
8.1.200.0070.00317.60
8.1.190.0000.00817.48
8.1.180.0030.00618.10
8.1.170.0050.00518.60
8.1.160.0030.00522.24
8.1.150.0040.00419.11
8.1.140.0040.00417.67
8.1.130.0020.00517.67
8.1.120.0000.00717.61
8.1.110.0040.00417.60
8.1.100.0050.00217.62
8.1.90.0000.00717.55
8.1.80.0070.00017.48
8.1.70.0060.00317.55
8.1.60.0000.00817.80
8.1.50.0040.00417.58
8.1.40.0030.00617.57
8.1.30.0040.00417.66
8.1.20.0040.00417.84
8.1.10.0060.00317.69
8.1.00.0000.00817.46
8.0.300.0040.00418.77
8.0.290.0030.00617.00
8.0.280.0080.00018.48
8.0.270.0070.00017.33
8.0.260.0040.00417.11
8.0.250.0030.00317.21
8.0.240.0030.00617.18
8.0.230.0040.00417.02
8.0.220.0050.00317.07
8.0.210.0040.00417.09
8.0.200.0030.00317.06
8.0.190.0080.00317.05
8.0.180.0040.00417.11
8.0.170.0050.00317.05
8.0.160.0050.00317.25
8.0.150.0040.00417.09
8.0.140.0000.00716.99
8.0.130.0000.00613.54
8.0.120.0050.00317.05
8.0.110.0000.00817.07
8.0.100.0080.00016.95
8.0.90.0000.00817.20
8.0.80.0030.01317.27
8.0.70.0040.00416.96
8.0.60.0050.00317.07
8.0.50.0000.00817.22
8.0.30.0110.01017.33
8.0.20.0130.01117.40
8.0.10.0040.00417.29
8.0.00.0080.01016.83
7.4.330.0030.00315.09
7.4.320.0000.00716.69
7.4.300.0040.00416.69
7.4.290.0000.00716.77
7.4.280.0040.00416.71
7.4.270.0000.00716.75
7.4.260.0040.00416.77
7.4.250.0060.00316.73
7.4.240.0040.00416.57
7.4.230.0000.00816.71
7.4.220.0100.00716.79
7.4.210.0100.00716.71
7.4.200.0000.00716.68
7.4.160.0100.00716.70
7.4.150.0120.01517.40
7.4.140.0160.01017.86
7.4.130.0140.00516.63
7.4.120.0080.01116.60
7.4.110.0070.01316.86
7.4.100.0070.01016.55
7.4.90.0040.01416.69
7.4.80.0120.00819.39
7.4.70.0070.01016.92
7.4.60.0060.01316.60
7.4.50.0080.00016.21
7.4.40.0120.01216.31
7.4.30.0130.00316.50
7.4.00.0090.00615.21
7.3.330.0000.00613.20
7.3.320.0000.00513.24
7.3.310.0030.00316.19
7.3.300.0030.00316.40
7.3.290.0110.00716.38
7.3.280.0050.01316.42
7.3.270.0160.00317.40
7.3.260.0120.01516.56
7.3.250.0100.00816.43
7.3.240.0150.00316.64
7.3.230.0120.00616.60
7.3.210.0070.01416.52
7.3.200.0170.00619.39
7.3.190.0030.02016.64
7.3.180.0080.01116.44
7.3.170.0090.01216.41
7.3.160.0140.00416.79
7.3.120.0090.00914.88
7.3.110.0070.01015.08
7.3.100.0130.00014.74
7.3.90.0060.00914.98
7.3.80.0060.00914.97
7.3.70.0030.00615.06
7.3.60.0000.01114.84
7.3.50.0030.00914.91
7.3.40.0060.00614.75
7.3.30.0040.01114.80
7.3.20.0060.00316.52
7.3.10.0030.00616.61
7.3.00.0030.00916.72
7.2.330.0140.00616.85
7.2.320.0120.00616.82
7.2.310.0070.01116.76
7.2.300.0080.00816.86
7.2.290.0160.00916.75
7.2.250.0080.00815.30
7.2.240.0100.01014.80
7.2.230.0070.01015.16
7.2.220.0040.01115.20
7.2.210.0080.00414.96
7.2.200.0060.00915.23
7.2.190.0030.01315.27
7.2.180.0030.00615.26
7.2.170.0040.01214.98
7.2.00.0030.00919.32
7.1.330.0070.00815.73
7.1.320.0040.01215.61
7.1.310.0000.01615.80
7.1.300.0030.01215.69
7.1.290.0070.00415.67
7.1.280.0060.00815.71
7.1.270.0000.00915.65
7.1.260.0100.00015.52
7.1.100.0000.01218.27
7.1.70.0020.00517.04
7.1.60.0030.01619.40
7.1.50.0120.00916.53
7.1.00.0100.07022.34
7.0.200.0030.00516.33
7.0.140.0070.06722.05
7.0.120.0130.06022.05
7.0.110.0070.07322.17
7.0.100.0030.06721.96
7.0.90.0070.05722.07
7.0.80.0070.05722.14
7.0.70.0030.08022.10
7.0.60.0000.06722.09
7.0.50.0030.06022.20
7.0.40.0070.07022.09
7.0.30.0030.07322.17
7.0.20.0070.06722.05
7.0.10.0000.06322.18
7.0.00.0030.05722.12
5.6.280.0030.07320.98
5.6.260.0000.05721.21
5.6.250.0030.05021.09
5.6.240.0030.05721.23
5.6.230.0030.07721.00
5.6.220.0070.06720.98
5.6.210.0000.07021.10
5.6.200.0030.07720.96
5.6.190.0030.06020.98
5.6.180.0000.07720.91
5.6.170.0000.05021.16
5.6.160.0030.07320.87
5.6.150.0070.07321.13
5.6.140.0070.04021.13
5.6.130.0000.03321.17
5.6.120.0030.04321.04
5.6.110.0130.06720.86
5.6.100.0000.07721.12
5.6.90.0030.06721.11
5.6.80.0030.05320.52
5.6.70.0000.07320.40
5.6.60.0000.04020.49
5.6.50.0000.05720.54
5.6.40.0070.06320.57
5.6.30.0030.06320.52
5.6.20.0030.07320.30
5.6.10.0000.06020.47
5.6.00.0000.07020.47
5.5.380.0000.05717.77
5.5.370.0030.06717.74
5.5.360.0000.05017.63
5.5.350.0070.07017.54
5.5.340.0000.06318.17
5.5.330.0000.04718.23
5.5.320.0000.06717.99
5.5.310.0000.05318.26
5.5.300.0000.06017.90
5.5.290.0000.03718.21
5.5.280.0030.05017.99
5.5.270.0000.06318.13
5.5.260.0000.07018.16
5.5.250.0100.03718.04
5.5.240.0030.06017.52
5.5.230.0030.07017.55
5.5.220.0030.04317.57
5.5.210.0030.04317.36
5.5.200.0030.06717.38
5.5.190.0000.05317.63
5.5.180.0070.06017.38
5.5.160.0000.07017.48
5.5.150.0070.06317.25
5.5.140.0100.05317.25
5.5.130.0030.06317.33
5.5.120.0070.06717.38
5.5.110.0000.06017.25
5.5.100.0000.06317.42
5.5.90.0000.06717.45
5.5.80.0000.07017.41
5.5.70.0030.07017.15
5.5.60.0030.06317.25
5.5.50.0030.04317.31
5.5.40.0070.05317.43
5.5.30.0000.05317.30
5.5.20.0030.04317.22
5.5.10.0070.06317.46
5.5.00.0000.06317.21
5.4.450.0000.03719.57
5.4.440.0000.03319.34
5.4.430.0030.06719.40
5.4.420.0030.04319.65
5.4.410.0100.05719.27
5.4.400.0000.07019.10
5.4.390.0000.05019.04
5.4.380.0000.05019.07
5.4.370.0000.06719.11
5.4.360.0000.05719.05
5.4.350.0000.04018.95
5.4.340.0030.07019.05
5.4.320.0030.07019.17
5.4.310.0070.06319.15
5.4.300.0000.07018.99
5.4.290.0030.06319.04
5.4.280.0030.04718.94
5.4.270.0030.06318.97
5.4.260.0070.06319.05
5.4.250.0030.04019.04
5.4.240.0100.06018.98
5.4.230.0030.06018.94
5.4.220.0000.07319.10
5.4.210.0000.04719.15
5.4.200.0030.05319.17
5.4.190.0030.05319.08
5.4.180.0070.04319.30
5.4.170.0000.06019.23
5.4.160.0000.06319.04
5.4.150.0000.07019.05
5.4.140.0100.06316.55
5.4.130.0000.06716.33
5.4.120.0070.06016.52
5.4.110.0000.05716.39
5.4.100.0000.04316.63
5.4.90.0000.05316.52
5.4.80.0000.06716.52
5.4.70.0000.05316.32
5.4.60.0070.02716.46
5.4.50.0030.02716.30
5.4.40.0030.03016.21
5.4.30.0000.03016.50
5.4.20.0030.04016.46
5.4.10.0000.03016.46
5.4.00.0070.02315.96

preferences:
46.67 ms | 401 KiB | 5 Q