Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 401 and 403]

url_finder class definition.

Copyright: Copyright (c) 2016 Blackboard Inc. (http://www.blackboard.com)
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 264 lines (10 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

url_finder:: (6 methods):
  http_link_stats()
  upgrade_http_links()
  domain_swap()
  get_select_search_in_column()
  process()
  check_domain_availability()


Class: url_finder  - X-Ref

Examines DB for non-https src or data links

http_link_stats($progress = null)   X-Ref
Returns a hash of what hosts are referred to over http and would need to be changed.

param: progress_bar $progress Progress bar keeping track of this process.
return: array Hash of domains with number of references as the value.

upgrade_http_links($progress = null)   X-Ref
Changes all resources referred to over http to https.

param: progress_bar $progress Progress bar keeping track of this process.
return: bool True upon success

domain_swap($table, $column, $domain, $search)   X-Ref
Replace http domains with https equivalent, with two types of exceptions
for less straightforward swaps.

param: string $table
param: database_column_info $column
param: string $domain
param: string $search search string that has prefix, protocol, domain name and one extra character,
return: void

get_select_search_in_column($columnname)   X-Ref
Returns SQL to be used to match embedded http links in the given column

param: string $columnname name of the column (ready to be used in the SQL query)
return: array

process($replacing = false, $progress = null)   X-Ref
Originally forked from core function db_search().

param: bool $replacing Whether or not to replace the found urls.
param: progress_bar $progress Progress bar keeping track of this process.
return: bool|array If $replacing, return true on success. If not, return hash of http urls to number of times used.

check_domain_availability($url)   X-Ref
Check if url is available (GET request returns 200)

param: string $url
return: bool