Checks for PHP mail in install.php and warns if mail used after install (#3056)
* Checks for PHP mail in install.php and warns if mail used after install. * fixed spacing in instal.php * Reconfigured warning message and code for PHP mail not existing or disabled. Removed the substitute mail function in inc/compatibility.php * fixed some spacing errors in install.php * Adds warning to error_log when call is made to unavailable PHP mail function and posts the warning to browser top if current user is admin. * adds newline at end of compatibility.php and $lang global to Mailer.class.php * Changes to handling of msg and `return false` as suggested by @phy25 * Removed tab from lilne 719 * removed additional tabs from Mailer.class.php * Update inc/Mailer.class.php removes unnecessary object * Update inc/Mailer.class.php changed msg styling for msg_managers_only warning for no PHP mail function * Update inc/Mailer.class.php * Update inc/Mailer.class.php
This commit is contained in:
parent
1af5896e44
commit
3f6872b1fc
|
@ -696,6 +696,7 @@ class Mailer {
|
|||
* @return bool true if the mail was successfully passed to the MTA
|
||||
*/
|
||||
public function send() {
|
||||
global $lang;
|
||||
$success = false;
|
||||
|
||||
// prepare hook data
|
||||
|
@ -754,6 +755,14 @@ class Mailer {
|
|||
$headers .= MAILHEADER_EOL.trim($data['headers']);
|
||||
}
|
||||
|
||||
if(!function_exists('mail')){
|
||||
$emsg = $lang['email_fail'] . $subject;
|
||||
error_log($emsg);
|
||||
msg(hsc($emsg), -1, __LINE__, __FILE__, MSG_MANAGERS_ONLY);
|
||||
$evt->advise_after();
|
||||
return false;
|
||||
}
|
||||
|
||||
// send the thing
|
||||
if($this->sendparam === null) {
|
||||
$success = @mail($to, $subject, $body, $headers);
|
||||
|
|
|
@ -79,4 +79,5 @@ if(!function_exists('gztell') && function_exists('gztell64')) {
|
|||
function gztell($zp) {
|
||||
return gztell64($zp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -319,6 +319,9 @@ $lang['i_modified'] = 'For security reasons this script will only wor
|
|||
You should either re-extract the files from the downloaded package or consult the complete
|
||||
<a href="http://dokuwiki.org/install">Dokuwiki installation instructions</a>';
|
||||
$lang['i_funcna'] = 'PHP function <code>%s</code> is not available. Maybe your hosting provider disabled it for some reason?';
|
||||
$lang['i_disabled'] = 'It has been disabled by your provider.';
|
||||
$lang['i_funcnmail'] = '<b>Note:</b> The PHP mail function is not available. %s' .
|
||||
' If it remains unavailable, you may install the <a href="http://dokuwiki.org/plugins/smtp">smtp plugin</a>.';
|
||||
$lang['i_phpver'] = 'Your PHP version <code>%s</code> is lower than the needed <code>%s</code>. You need to upgrade your PHP install.';
|
||||
$lang['i_mbfuncoverload'] = 'mbstring.func_overload must be disabled in php.ini to run DokuWiki.';
|
||||
$lang['i_urandom'] = 'DokuWiki cannot create cryptographically secure numbers for cookies. You may want to check your open_basedir settings in php.ini for proper <code>/dev/urandom</code> access.';
|
||||
|
@ -378,6 +381,7 @@ $lang['media_update'] = 'Upload new version';
|
|||
$lang['media_restore'] = 'Restore this version';
|
||||
$lang['media_acl_warning'] = 'This list might not be complete due to ACL restrictions and hidden pages.';
|
||||
|
||||
$lang['email_fail'] = 'PHP mail() missing or disabled. The following email was not sent: ';
|
||||
$lang['currentns'] = 'Current namespace';
|
||||
$lang['searchresult'] = 'Search Result';
|
||||
$lang['plainhtml'] = 'Plain HTML';
|
||||
|
|
12
install.php
12
install.php
|
@ -581,7 +581,7 @@ function check_functions(){
|
|||
|
||||
$funcs = explode(' ','addslashes call_user_func chmod copy fgets '.
|
||||
'file file_exists fseek flush filesize ftell fopen '.
|
||||
'glob header ignore_user_abort ini_get mail mkdir '.
|
||||
'glob header ignore_user_abort ini_get mkdir '.
|
||||
'ob_start opendir parse_ini_file readfile realpath '.
|
||||
'rename rmdir serialize session_start unlink usleep '.
|
||||
'preg_replace file_get_contents htmlspecialchars_decode '.
|
||||
|
@ -592,6 +592,16 @@ function check_functions(){
|
|||
$funcs[] = 'utf8_decode';
|
||||
}
|
||||
|
||||
if(!function_exists('mail')){
|
||||
if(strpos(ini_get('disable_functions'),'mail') !== false) {
|
||||
$disabled = $lang['i_disabled'];
|
||||
}
|
||||
else {
|
||||
$disabled = "";
|
||||
}
|
||||
$error[] = sprintf($lang['i_funcnmail'],$disabled);
|
||||
}
|
||||
|
||||
foreach($funcs as $func){
|
||||
if(!function_exists($func)){
|
||||
$error[] = sprintf($lang['i_funcna'],$func);
|
||||
|
|
Loading…
Reference in New Issue