1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110:
<?php
abstract class Module_Support_Auth extends Module_Skeleton
{
protected function sendNotice($what, $args)
{
$key = 'notify.' . $what . 'change';
$donotify = \Preferences::get($key, true);
if (!$donotify) {
return true;
}
$hostname = "UNKNOWN";
$location = null;
if ($tmp = $this->dns_gethostbyaddr_t($args['ip'], 3000)) {
$hostname = $tmp;
}
$location = Util_Geoip::locate($args['ip']);
$gmap = "https://www.google.com/maps/preview/@" . $location['latitude'] . "," . $location['longitude'] . ",8z";
$vars = array_replace_recursive([
'what' => $what,
'domain' => $this->domain,
'latitude' => $location['latitude'],
'longitude' => $location['longitude'],
'city' => $location['city'],
'state' => $location['state'],
'country' => $location['country'],
'gmapurl' => $gmap,
'ip' => $args['ip'],
'hostname' => $hostname,
'username' => $this->username,
'config' => [
'geoip' => true
],
], $args);
if (!$vars['email']) {
return warn("no email configured - ignoring alert notification for %s change for `%s'", $what,
$vars['username']);
}
$blade = \BladeLite::factory('views/email');
$body = $blade->make('auth.change', $vars)->render();
$opts = array(
'html_charset' => 'utf-8',
'text_charset' => 'utf-8'
);
$from = Crm_Module::FROM_NAME . ' <' . Crm_Module::FROM_ADDRESS . '>';
$headers = array(
'Sender' => $from,
'From' => $from
);
$mime = new Mail_Mime($opts);
$mime->setHTMLBody($body);
$mime->setTXTBody(strip_tags($body));
$headers = $mime->txtHeaders($headers);
$msg = $mime->get();
return Mail::send(
$vars['email'],
ucwords($what) . ' Changed - ' . $vars['domain'],
$msg,
$headers
);
}
protected function rebuildMap() {
$tcd = \Opcenter\Map::load(\Opcenter\Map::DOMAIN_MAP, 'cd');
return $tcd->copy(\Opcenter\Map::DOMAIN_TXT_MAP);
}
public static function getAuthService($platform_version = PLATFORM_VERSION): string
{
return version_compare($platform_version, '7.5', '>=') ?
'auth' : 'siteinfo';
}
}