Example #1
0
 public function update_observer($type, $message, $errfile, $errline, $errcontext, $backtrace)
 {
     $mail = Variable::get('error_mail');
     if ($mail) {
         $backtrace = htmlspecialchars_decode(str_replace(array('<br />', '&nbsp;'), array("\n", ' '), $backtrace));
         $x = "who=" . Base_AclCommon::get_user() . "\ntype=" . $type . "\nmessage=" . $message . "\nerror file=" . $errfile . "\nerror line=" . $errline . "\n" . $backtrace;
         $d = ModuleManager::get_data_dir('Base/Error') . md5($x) . '.txt';
         file_put_contents($d, $x);
         $url = get_epesi_url();
         Base_MailCommon::send($mail, 'Epesi Error - ' . $url, substr($x, 0, strpos($x, "error backtrace")) . "\n" . $url . '/' . $d, null, null, false, true);
     }
     return true;
 }
Example #2
0
 public function test_mail_config($email)
 {
     ob_start();
     $ret = Base_MailCommon::send($email, __('E-mail configuration test'), __('If you are reading this, it means that your e-mail server configuration at %s is working properly.', array(get_epesi_url())));
     $msg = ob_get_clean();
     if ($msg) {
         print '<span class="important_notice">' . $msg . '</span>';
     }
     if ($ret) {
         Base_StatusBarCommon::message(__('E-mail was sent successfully'));
     } else {
         Base_StatusBarCommon::message(__('An error has occured'), 'error');
     }
     return false;
 }
Example #3
0
 public static function send_email_notifications($event_id)
 {
     $event = DB::GetRow('SELECT * FROM utils_watchdog_event WHERE id=%d', array($event_id));
     if (!$event) {
         return;
     }
     $category_id = $event['category_id'];
     $id = $event['internal_id'];
     $message = $event['message'];
     $subscribers = self::get_subscribers($category_id, $id);
     $c_user = Acl::get_user();
     self::email_mode(true);
     foreach ($subscribers as $user_id) {
         $wants_email = Base_User_SettingsCommon::get('Utils_Watchdog', 'email', $user_id);
         if (!$wants_email) {
             continue;
         }
         Acl::set_user($user_id);
         Base_LangCommon::load();
         $email_data = self::display_events($category_id, array($event_id => $message), $id, true);
         if (!$email_data) {
             continue;
         }
         $contact = Utils_RecordBrowserCommon::get_id('contact', 'login', $user_id);
         if (!$contact) {
             continue;
         }
         $email = Utils_RecordBrowserCommon::get_value('contact', $contact, 'email');
         if (!$email) {
             continue;
         }
         $title = __('%s notification - %s - %s', array(EPESI, $email_data['category'], strip_tags($email_data['title'])));
         Base_MailCommon::send($email, $title, $email_data['events'], null, null, true);
     }
     Acl::set_user($c_user);
     Base_LangCommon::load();
     self::email_mode(false);
 }
Example #4
0
    public static function cron2() {
        $interval = DB::is_postgresql() ? DB::qstr('4 minute') : '4 minute';
		$arr = DB::GetAll('SELECT m.*,u.* FROM utils_messenger_message m INNER JOIN utils_messenger_users u ON u.message_id=m.id WHERE u.follow=0 AND m.alert_on+INTERVAL ' . $interval . ' <%T',array(time()));
		foreach($arr as $row) {
			Acl::set_user($row['user_login_id']);
			$always_follow = Base_User_SettingsCommon::get('Utils_Messenger','always_follow_me');
			if(!$always_follow && $row['done']) continue;
			ob_start();
			$fret = call_user_func_array(unserialize($row['callback_method']),unserialize($row['callback_args']));
			ob_end_clean();
			DB::Execute('UPDATE utils_messenger_users SET follow=1 WHERE message_id=%d AND user_login_id=%d',array($row['id'],$row['user_login_id']));

			$mail = Base_User_SettingsCommon::get('Utils_Messenger','mail');
			if($mail) {
				$msg = __('Alert on: %s',array(Base_RegionalSettingsCommon::time2reg($row['alert_on'],2)))."\n".$fret."\n".($row['message']?__('Alarm comment: %s',array($row['message'])):'');
				Base_MailCommon::send($mail,'Alert!',$msg);
			}
			Acl::set_user();
		}
		
		return '';
	}
Example #5
0
	public static function new_event($category_name, $id, $message) {
		if(self::$disabled) return;
		$category_id = self::get_category_id($category_name, false);
		if (!$category_id) return;
		DB::Execute('INSERT INTO utils_watchdog_event (category_id, internal_id, message, event_time) VALUES (%d,%d,%s,%T)',array($category_id,$id,$message,time()));
		$event_id = DB::Insert_ID('utils_watchdog_event', 'id');
		Utils_WatchdogCommon::notified($category_name,$id);
		$count = DB::GetOne('SELECT COUNT(*) FROM utils_watchdog_event WHERE category_id=%d AND internal_id=%d', array($category_id,$id));
		if ($count==1) {
			$subscribers = self::get_subscribers($category_id);
			foreach ($subscribers as $s)
				self::user_subscribe($s, $category_name, $id);
		}
        $subscribers = self::get_subscribers($category_name, $id);

		$c_user = Acl::get_user();
        self::email_mode(true);
		foreach ($subscribers as $user_id) {
            if ($user_id==$c_user) continue;
            $wants_email = Base_User_SettingsCommon::get('Utils_Watchdog', 'email', $user_id);
            if (!$wants_email) continue;
            Acl::set_user($user_id);
            Base_LangCommon::load();
            $email_data = self::display_events($category_id, array($event_id => $message), $id, true);
            if (!$email_data) continue;
            $contact = Utils_RecordBrowserCommon::get_id('contact', 'login', $user_id);
            if (!$contact) continue;
            $email = Utils_RecordBrowserCommon::get_value('contact', $contact, 'email');
            if (!$email) continue;
            $title = __('%s notification - %s - %s', array(EPESI, $email_data['category'], strip_tags($email_data['title'])));
            Base_MailCommon::send($email, $title, $email_data['events'], null, null, true);
        }
		Acl::set_user($c_user);
        Base_LangCommon::load();
        self::email_mode(false);
    }