1
0
mirror of https://github.com/e107inc/e107.git synced 2025-02-07 15:51:18 +01:00
php-e107/e107_handlers/notify_class.php

182 lines
4.4 KiB
PHP
Raw Normal View History

2006-12-02 04:36:16 +00:00
<?php
/*
2008-12-21 18:15:04 +00:00
* e107 website system
*
* Copyright (C) 2001-2008 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Forum plugin notify configuration
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/notify_class.php,v $
* $Revision: 1.4 $
* $Date: 2008-12-21 18:15:04 $
* $Author: mcfly_e107 $
*
2006-12-02 04:36:16 +00:00
*/
if (!defined('e107_INIT')) { exit; }
2008-12-21 18:15:04 +00:00
class notify
{
2006-12-02 04:36:16 +00:00
var $notify_prefs;
2008-04-26 14:34:17 +00:00
function notify()
{
2006-12-02 04:36:16 +00:00
global $sysprefs, $e_event, $eArrayStorage;
2008-12-21 18:15:04 +00:00
$this->notify_prefs = $sysprefs->get('notify_prefs');
$this->notify_prefs = $eArrayStorage->ReadArray($this->notify_prefs);
foreach ($this->notify_prefs['event'] as $id => $status)
2008-04-26 14:34:17 +00:00
{
if ($status['class'] != 255)
{
2008-12-21 18:15:04 +00:00
$e_event->register($id, 'notify_'.$id);
2006-12-02 04:36:16 +00:00
}
}
2008-04-26 14:34:17 +00:00
include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_notify.php');
2006-12-02 04:36:16 +00:00
}
2008-12-21 18:15:04 +00:00
function send($id, $subject, $message)
{
2006-12-02 04:36:16 +00:00
global $sql,$tp;
e107_require_once(e_HANDLER.'mail.php');
$subject = SITENAME.': '.$subject;
2008-12-21 18:15:04 +00:00
if ($this->notify_prefs['event'][$id]['class'] == 250)
2008-04-26 14:34:17 +00:00
{
2006-12-02 04:36:16 +00:00
sendemail(SITEADMINEMAIL, $tp->toEmail($subject), $tp->toEmail($message));
2008-04-26 14:34:17 +00:00
}
else if (is_numeric($this -> notify_prefs['event'][$id]['class']))
{
2008-12-21 18:15:04 +00:00
if ($this->notify_prefs['event'][$id]['class'] == '254')
2008-04-26 14:34:17 +00:00
{
2008-12-21 18:15:04 +00:00
$sql->db_Select('user', 'user_email', "user_admin = 1");
2008-04-26 14:34:17 +00:00
}
2008-12-21 18:15:04 +00:00
else if ($this->notify_prefs['event'][$id]['class'] == '253')
2008-04-26 14:34:17 +00:00
{
2008-12-21 18:15:04 +00:00
$sql->db_Select('user', 'user_email',"user_ban= 0 ");
2008-04-26 14:34:17 +00:00
}
else
{
2008-12-21 18:15:04 +00:00
$sql->db_Select('user', 'user_email', "user_class REGEXP '(^|,)(".$this->notify_prefs['event'][$id]['class'].")(,|$)'");
2006-12-02 04:36:16 +00:00
}
2008-12-21 18:15:04 +00:00
while ($email = $sql->db_Fetch())
2008-04-26 14:34:17 +00:00
{
2006-12-02 04:36:16 +00:00
sendemail($email['user_email'], $tp->toEmail($subject), $tp->toEmail($message));
}
2008-04-26 14:34:17 +00:00
}
2008-12-21 18:15:04 +00:00
else if ($this->notify_prefs['event'][$id]['class'] == 'email')
2008-04-26 14:34:17 +00:00
{
2008-12-21 18:15:04 +00:00
sendemail($this->notify_prefs['event'][$id]['email'], $tp->toEmail($subject), $tp->toEmail($message));
2006-12-02 04:36:16 +00:00
}
}
}
2008-12-21 18:15:04 +00:00
2006-12-02 04:36:16 +00:00
global $nt;
2008-12-21 18:15:04 +00:00
$e107->notify = new notify;
$nt = &$e107->notify;
2006-12-02 04:36:16 +00:00
2008-12-21 18:15:04 +00:00
function notify_usersup($data)
{
2006-12-02 04:36:16 +00:00
global $nt;
foreach ($data as $key => $value)
{
if($key != "password1" && $key != "password2" && $key != "email_confirm" && $key != "register")
{
if(is_array($value)) // show user-extended values.
{
2008-12-21 18:15:04 +00:00
foreach($value as $k => $v)
2006-12-02 04:36:16 +00:00
{
2008-12-21 18:15:04 +00:00
$message .= str_replace("user_","",$k).': '.$v.'<br />';
2006-12-02 04:36:16 +00:00
}
}
else
{
$message .= $key.': '.$value.'<br />';
}
}
}
2008-12-21 18:15:04 +00:00
$nt->send('usersup', NT_LAN_US_1, $message);
2006-12-02 04:36:16 +00:00
}
2008-12-21 18:15:04 +00:00
function notify_userveri($data)
{
2006-12-02 04:36:16 +00:00
global $nt, $e107;
$msgtext = NT_LAN_UV_2.$data['user_id']."\n";
$msgtext .= NT_LAN_UV_3.$data['user_loginname']."\n";
2007-03-22 21:26:27 +00:00
$msgtext .= NT_LAN_UV_4.$e107->getip();
2008-12-21 18:15:04 +00:00
$nt->send('userveri', NT_LAN_UV_1, $msgtext);
2006-12-02 04:36:16 +00:00
}
2008-12-21 18:15:04 +00:00
function notify_login($data)
{
2006-12-02 04:36:16 +00:00
global $nt;
foreach ($data as $key => $value) {
$message .= $key.': '.$value.'<br />';
}
2008-12-21 18:15:04 +00:00
$nt->send('login', NT_LAN_LI_1, $message);
2006-12-02 04:36:16 +00:00
}
2008-12-21 18:15:04 +00:00
function notify_logout()
{
2006-12-02 04:36:16 +00:00
global $nt;
2008-12-21 18:15:04 +00:00
$nt->send('logout', NT_LAN_LO_1, USERID.'. '.USERNAME.' '.NT_LAN_LO_2);
2006-12-02 04:36:16 +00:00
}
2008-12-21 18:15:04 +00:00
function notify_flood($data)
{
2006-12-02 04:36:16 +00:00
global $nt;
2008-12-21 18:15:04 +00:00
$nt->send('flood', NT_LAN_FL_1, NT_LAN_FL_2.': '.$data);
2006-12-02 04:36:16 +00:00
}
2008-12-21 18:15:04 +00:00
function notify_subnews($data)
{
2006-12-02 04:36:16 +00:00
global $nt,$tp;
foreach ($data as $key => $value) {
$message .= $key.': '.$value.'<br />';
}
2008-12-21 18:15:04 +00:00
$nt->send('subnews', NT_LAN_SN_1, $message);
2006-12-02 04:36:16 +00:00
}
2008-12-21 18:15:04 +00:00
function notify_newspost($data)
{
2006-12-02 04:36:16 +00:00
global $nt;
$message = '<b>'.$data['news_title'].'</b><br /><br />'.$data['news_summary'].'<br /><br />'.$data['data'].'<br /><br />'.$data['news_extended'];
2008-12-21 18:15:04 +00:00
$nt->send('newspost', $data['news_title'], $message);
2006-12-02 04:36:16 +00:00
}
2008-12-21 18:15:04 +00:00
function notify_newsupd($data)
{
2006-12-02 04:36:16 +00:00
global $nt;
$message = '<b>'.$data['news_title'].'</b><br /><br />'.$data['news_summary'].'<br /><br />'.$data['data'].'<br /><br />'.$data['news_extended'];
2008-12-21 18:15:04 +00:00
$nt->send('newsupd', NT_LAN_NU_1.': '.$data['news_title'], $message);
2006-12-02 04:36:16 +00:00
}
2008-12-21 18:15:04 +00:00
function notify_newsdel($data)
{
2006-12-02 04:36:16 +00:00
global $nt;
2008-12-21 18:15:04 +00:00
$nt->send('newsdel', NT_LAN_ND_1, NT_LAN_ND_2.': '.$data);
2006-12-02 04:36:16 +00:00
}
2008-12-21 18:15:04 +00:00
function notify_fileupload($data)
{
2006-12-02 04:36:16 +00:00
global $nt;
$message = '<b>'.$data['upload_name'].'</b><br /><br />'.$data['upload_description'].'<br /><br />'.$data['upload_size'].'<br /><br />'.$data['upload_user'];
2008-12-21 18:15:04 +00:00
$nt->send('fileupload', $data['upload_name'], $message);
2006-12-02 04:36:16 +00:00
}
2008-12-21 18:15:04 +00:00
if (isset($nt->notify_prefs['plugins']))
{
foreach ($nt->notify_prefs['plugins'] as $plugin_id => $plugin_settings)
{
2006-12-02 04:36:16 +00:00
if(is_readable(e_PLUGIN.$plugin_id.'/e_notify.php'))
{
require_once(e_PLUGIN.$plugin_id.'/e_notify.php');
}
}
}
2008-12-21 18:15:04 +00:00
?>