run(); if($retval != UPDATE_SUCCESS) { $source = t('Source code of failed update: ') . "\n\n" . @file_get_contents('Zotlabs/Update/' . $s . '.php'); // Prevent sending hundreds of thousands of emails by creating // a lockfile. $lockfile = 'store/[data]/mailsent'; if ((file_exists($lockfile)) && (filemtime($lockfile) > (time() - 86400))) return; @unlink($lockfile); //send the administrator an e-mail file_put_contents($lockfile, $x); $r = q("select account_language from account where account_email = '%s' limit 1", dbesc(\App::$config['system']['admin_email']) ); push_lang(($r) ? $r[0]['account_language'] : 'en'); z_mail( [ 'toEmail' => \App::$config['system']['admin_email'], 'messageSubject' => sprintf( t('Update Error at %s'), z_root()), 'textVersion' => replace_macros(get_intltext_template('update_fail_eml.tpl'), [ '$sitename' => \App::$config['system']['sitename'], '$siteurl' => z_root(), '$update' => $x, '$error' => sprintf( t('Update %s failed. See error logs.'), $x), '$baseurl' => z_root(), '$source' => $source ] ) ] ); //try the logger logger('CRITICAL: Update Failed: ' . $x); pop_lang(); } else { Config::Set('database',$s, 'success'); } } } Config::Set('system', 'db_version', $db_revision); } } }