Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403] [Versions 401 and 403] [Versions 402 and 403]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Search and replace http -> https throughout all texts in the whole database 19 * 20 * @package tool_httpsreplace 21 * @copyright Copyright (c) 2016 Blackboard Inc. (http://www.blackboard.com) 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 define('NO_OUTPUT_BUFFERING', true); 26 27 require_once(__DIR__ . '/../../../config.php'); 28 require_once($CFG->dirroot . '/course/lib.php'); 29 require_once($CFG->libdir . '/adminlib.php'); 30 31 admin_externalpage_setup('toolhttpsreplace'); 32 33 $context = context_system::instance(); 34 35 $PAGE->set_context($context); 36 $PAGE->set_url(new moodle_url('/admin/tool/httpsreplace/index.php')); 37 $PAGE->set_title(get_string('pageheader', 'tool_httpsreplace')); 38 $PAGE->set_pagelayout('admin'); 39 40 echo $OUTPUT->header(); 41 42 echo $OUTPUT->heading(get_string('pageheader', 'tool_httpsreplace')); 43 44 if (!$DB->replace_all_text_supported()) { 45 echo $OUTPUT->notification(get_string('notimplemented', 'tool_httpsreplace')); 46 echo $OUTPUT->footer(); 47 die; 48 } 49 50 if (!is_https()) { 51 echo $OUTPUT->notification(get_string('httpwarning', 'tool_httpsreplace'), 'warning'); 52 } 53 54 $form = new \tool_httpsreplace\form(); 55 56 $finder = new \tool_httpsreplace\url_finder(); 57 58 $PAGE->set_cacheable(false); 59 $progressbar = new progress_bar(); 60 61 // Preemptively reset the navcache before closing, so it remains the same on shutdown. 62 navigation_cache::destroy_volatile_caches(); 63 \core\session\manager::write_close(); 64 65 // Prepare for streamed output. 66 echo $OUTPUT->footer(); 67 echo $OUTPUT->select_element_for_append(); 68 69 if (!$data = $form->get_data()) { 70 71 echo $progressbar->create(); 72 73 $results = $finder->http_link_stats($progressbar); 74 75 $progressbar->update_full(100, get_string('complete', 'tool_httpsreplace')); 76 77 if (empty($results)) { 78 echo '<p>'.get_string('oktoprocede', 'tool_httpsreplace').'</p>'; 79 } else { 80 arsort($results); 81 $table = new html_table(); 82 $table->id = 'plugins-check'; 83 $table->head = array( 84 get_string('domain', 'tool_httpsreplace'), 85 get_string('count', 'tool_httpsreplace'), 86 ); 87 $data = array(); 88 foreach ($results as $domain => $count) { 89 $cleandomain = format_text($domain, FORMAT_PLAIN); 90 $data[] = [$cleandomain, $count]; 91 } 92 $table->data = $data; 93 echo html_writer::table($table); 94 echo get_string('domainexplainhelp', 'tool_httpsreplace'); 95 } 96 echo $OUTPUT->notification(get_string('takeabackupwarning', 'tool_httpsreplace'), 'warning'); 97 $form->display(); 98 } else { 99 // Scroll to the end when finished. 100 $PAGE->requires->js_init_code("window.scrollTo(0, document.body.scrollHeight);"); 101 102 echo html_writer::tag('p', get_string('replacing', 'tool_httpsreplace')); 103 104 echo $progressbar->create(); 105 106 echo $OUTPUT->box_start(); 107 $finder->upgrade_http_links($progressbar); 108 echo $OUTPUT->box_end(); 109 110 $progressbar->update_full(100, get_string('complete', 'tool_httpsreplace')); 111 112 echo $OUTPUT->continue_button(new moodle_url('/admin/settings.php', ['section' => 'httpsecurity'])); 113 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body