Esempio n. 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;
 }
Esempio n. 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;
 }
Esempio n. 3
0
 public function submit_recover($data)
 {
     $mail = $data['mail'];
     $username = $data['username'];
     if (DEMO_MODE && $username == 'admin') {
         print 'In demo you cannot recover \'admin\' user password. If you want to login please type \'admin\' as password.';
         return false;
     }
     $user_id = Base_UserCommon::get_user_id($username);
     DB::Execute('DELETE FROM user_reset_pass WHERE created_on<%T', array(time() - 3600 * 2));
     if ($user_id === false) {
         print 'No such user!';
         return false;
     }
     $hash = md5($user_id . '' . time());
     DB::Execute('INSERT INTO user_reset_pass(user_login_id,hash_id,created_on) VALUES (%d,%s,%T)', array($user_id, $hash, time()));
     $subject = __('Password recovery');
     $message = __('A password recovery for the account with the e-mail address %s has been requested.', array($mail)) . "\n\n" . __('If you want to reset your password, visit the following URL:') . "\n" . get_epesi_url() . '/modules/Base/User/Login/reset_pass.php?hash=' . $hash . "\n" . __('or just ignore this message and your login and password will remain unchanged.') . "\n\n" . __('If you did not use the Password Recovery form, inform your administrator about a potential unauthorized attempt to login using your credentials.') . "\n\n" . __('This e-mail was generated automatically and you do not need to respond to it.');
     $sendMail = Base_MailCommon::send_critical($mail, $subject, $message);
     return true;
 }
Esempio n. 4
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);
 }
Esempio n. 5
0
 /**
  * Send mail with login and password to address....
  * 
  * @param string username
  * @param string password
  * @param string destination mail address
  */
 public static function send_mail_with_password($username, $pass, $mail, $recovery = false)
 {
     $url = get_epesi_url();
     $subject = __('Your account at %s', array($url));
     $header = Variable::get('add_user_email_header', '');
     $body = $header ? $header . "\n\n" : '';
     if ($recovery) {
         $body .= __('This e-mail is to inform you that your password at %s has been reset.', array($url));
     } else {
         $body .= __('This e-mail is to inform you that a user account was setup for you at: %s.', array($url));
     }
     $body .= "\n" . __('Your username is: %s', array($username)) . "\n" . __('Your password is: %s', array($pass)) . "\n\n" . __('For security reasons it is recommened that you log in immediately and change your password.') . "\n\n" . __('This e-mail was generated automatically and you do not need to respond to it.');
     return Base_MailCommon::send_critical($mail, $subject, $body);
 }
Esempio n. 6
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 '';
	}
Esempio n. 7
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);
    }