MDL-61232 core: Remove process_email.php and anything related to it

This commit is contained in:
meirzamoodle 2024-10-01 20:18:51 +07:00
parent ec7711b9a6
commit c299f69e9f
6 changed files with 49 additions and 113 deletions

View File

@ -0,0 +1,6 @@
issueNumber: MDL-61232
notes:
core:
- message: |
moodle_process_email() has been deprecated with the removal of the unused and non-functioning admin/process_email.php.
type: removed

View File

@ -1,80 +0,0 @@
#!/usr/bin/php -f
<?php
//error_reporting(0);
//ini_set('display_errors',0);
require_once(__DIR__ . '/../config.php');
$tmp = explode('@',$_ENV['RECIPIENT']);
$address = $tmp[0];
// BOUNCE EMAILS TO NOREPLY
if ($_ENV['RECIPIENT'] == $CFG->noreplyaddress) {
$user = new stdClass();
$user->email = $_ENV['SENDER'];
if (!validate_email($user->email)) {
die();
}
$site = get_site();
$subject = get_string('noreplybouncesubject','moodle',format_string($site->fullname));
$body = get_string('noreplybouncemessage','moodle',format_string($site->fullname))."\n\n";
$fd = fopen('php://stdin','r');
if ($fd) {
while(!feof($fd)) {
$body .= fgets($fd);
}
fclose($fd);
}
$user->id = 0; // to prevent anything annoying happening
$from->firstname = null;
$from->lastname = null;
$from->email = '<>';
$from->maildisplay = true;
email_to_user($user,$from,$subject,$body);
die ();
}
/// ALL OTHER PROCESSING
// we need to split up the address
$prefix = substr($address,0,4);
$mod = substr($address,4,2);
$modargs = substr($address,6,-16);
$hash = substr($address,-16);
if (substr(md5($prefix.$mod.$modargs.$CFG->siteidentifier),0,16) != $hash) {
die("HASH DIDN'T MATCH!\n");
}
list(,$modid) = unpack('C',base64_decode($mod.'=='));
if ($modid == '0') { // special
$modname = 'moodle';
}
else {
$modname = $DB->get_field("modules", "name", array("id"=>$modid));
include_once('mod/'.$modname.'/lib.php');
}
$function = $modname.'_process_email';
if (!function_exists($function)) {
die();
}
$fd = fopen('php://stdin','r');
if (!$fd) {
exit();
}
while(!feof($fd)) {
$body .= fgets($fd);
}
$function($modargs,$body);
fclose($fd);

View File

@ -134,3 +134,5 @@ filterbothactive,core_grades
filterbyname,core_grades
filterfirstactive,core_grades
filterlastactive,core_grades
noreplybouncemessage,core
noreplybouncesubject,core

View File

@ -1551,10 +1551,6 @@ $string['nopotentialcreators'] = 'No potential course creators';
$string['nopotentialstudents'] = 'No potential students';
$string['nopotentialteachers'] = 'No potential teachers';
$string['norecentactivity'] = 'No recent activity';
$string['noreplybouncemessage'] = 'You have replied to a no-reply email address. If you were attempting to reply to a forum post, please instead reply using the {$a} forums.
Following is the content of your email:';
$string['noreplybouncesubject'] = '{$a} - bounced email.';
$string['noreplyname'] = 'Do not reply to this email';
$string['noresetrecord'] = 'There is no record of that reset request. Please initiate a new password reset request.';
$string['noresults'] = 'No results';
@ -2522,5 +2518,9 @@ line at the top of your web browser window.
Cheers from the \'{$a->sitename}\' administrator,
{$a->signoff}';
$string['noreplybouncemessage'] = 'You have replied to a no-reply email address. If you were attempting to reply to a forum post, please instead reply using the {$a} forums.
Following is the content of your email:';
$string['noreplybouncesubject'] = '{$a} - bounced email.';
$string['registrationcontactno'] = 'No, I do not want to be contacted by other people';
$string['registrationcontactyes'] = 'Yes, provide a form for other Moodlers to contact me';

View File

@ -785,3 +785,40 @@ function plagiarism_get_file_results(): void {
function plagiarism_update_status(): void {
\core\deprecation::emit_deprecation_if_present(__FUNCTION__);
}
/**
* ?
*
* @param string $modargs
* @param string $body Currently unused
*
* @deprecated Since Moodle 5.0
* @todo Final deprecation on Moodle 6.0. See MDL-83366.
*/
#[\core\attribute\deprecated(
replacement: null,
since: '5.0',
mdl: 'MDL-83366',
reason: 'The function is no longer used with the removal of the unused and non-functioning admin/process_email.php.',
)]
function moodle_process_email($modargs, $body) {
\core\deprecation::emit_deprecation_if_present(__FUNCTION__);
global $DB;
// The first char should be an unencoded letter. We'll take this as an action.
switch ($modargs[0]) {
case 'B': { // Bounce.
list(, $userid) = unpack('V', base64_decode(substr($modargs, 1, 8)));
if ($user = $DB->get_record("user", array('id' => $userid), "id,email")) {
// Check the half md5 of their email.
$md5check = substr(md5($user->email), 0, 16);
if ($md5check == substr($modargs, -16)) {
set_bounce_count($user);
}
// Else maybe they've already changed it?
}
}
break;
// Maybe more later?
}
}

View File

@ -5355,35 +5355,6 @@ function generate_email_processing_address($modid, $modargs) {
return $header . substr(md5($header.get_site_identifier()), 0, 16).'@'.$CFG->maildomain;
}
/**
* ?
*
* @todo Finish documenting this function
*
* @param string $modargs
* @param string $body Currently unused
*/
function moodle_process_email($modargs, $body) {
global $DB;
// The first char should be an unencoded letter. We'll take this as an action.
switch ($modargs[0]) {
case 'B': { // Bounce.
list(, $userid) = unpack('V', base64_decode(substr($modargs, 1, 8)));
if ($user = $DB->get_record("user", array('id' => $userid), "id,email")) {
// Check the half md5 of their email.
$md5check = substr(md5($user->email), 0, 16);
if ($md5check == substr($modargs, -16)) {
set_bounce_count($user);
}
// Else maybe they've already changed it?
}
}
break;
// Maybe more later?
}
}
// CORRESPONDENCE.
/**