Update admin_message.php

This commit is contained in:
Axel Guckelsberger
2013-04-27 10:56:34 +03:00
parent 2d6d3349cf
commit 54fc4758d9

View File

@@ -22,79 +22,60 @@ define('AREA', 'admin');
/** /**
* Include our init.php, which manages Sessions, Language etc. * Include our init.php, which manages Sessions, Language etc.
*/ */
require('./lib/init.php');
require ("./lib/init.php"); if (isset($_POST['id'])) {
if(isset($_POST['id']))
{
$id = intval($_POST['id']); $id = intval($_POST['id']);
} } elseif (isset($_GET['id'])) {
elseif(isset($_GET['id']))
{
$id = intval($_GET['id']); $id = intval($_GET['id']);
} }
if($page == 'message') if ($page == 'message') {
{ if ($action == '') {
if($action == '') $log->logAction(ADM_ACTION, LOG_NOTICE, 'viewed panel_message');
{
$log->logAction(ADM_ACTION, LOG_NOTICE, "viewed panel_message");
if(isset($_POST['send']) if (isset($_POST['send'])
&& $_POST['send'] == 'send') && $_POST['send'] == 'send'
{ ) {
if($_POST['receipient'] == 0 if ($_POST['receipient'] == 0
&& $userinfo['customers_see_all'] == '1') && $userinfo['customers_see_all'] == '1'
{ ) {
$log->logAction(ADM_ACTION, LOG_NOTICE, "sending messages to admins"); $log->logAction(ADM_ACTION, LOG_NOTICE, 'sending messages to admins');
$result = $db->query('SELECT `name`, `email` FROM `' . TABLE_PANEL_ADMINS . "`"); $result = $db->query('SELECT `name`, `email` FROM `' . TABLE_PANEL_ADMINS . "`");
} } elseif ($_POST['receipient'] == 1) {
elseif($_POST['receipient'] == 1) if ($userinfo['customers_see_all'] == '1') {
{ $log->logAction(ADM_ACTION, LOG_NOTICE, 'sending messages to ALL customers');
if($userinfo['customers_see_all'] == "1")
{
$log->logAction(ADM_ACTION, LOG_NOTICE, "sending messages to ALL customers");
$result = $db->query('SELECT `firstname`, `name`, `email` FROM `' . TABLE_PANEL_CUSTOMERS . "`"); $result = $db->query('SELECT `firstname`, `name`, `email` FROM `' . TABLE_PANEL_CUSTOMERS . "`");
} } else {
else $log->logAction(ADM_ACTION, LOG_NOTICE, 'sending messages to customers');
{
$log->logAction(ADM_ACTION, LOG_NOTICE, "sending messages to customers");
$result = $db->query('SELECT `firstname`, `name`, `email` FROM `' . TABLE_PANEL_CUSTOMERS . "` WHERE `adminid`='" . $userinfo['adminid'] . "'"); $result = $db->query('SELECT `firstname`, `name`, `email` FROM `' . TABLE_PANEL_CUSTOMERS . "` WHERE `adminid`='" . $userinfo['adminid'] . "'");
} }
} } else {
else
{
standard_error('noreceipientsgiven'); standard_error('noreceipientsgiven');
} }
$subject = $_POST['subject']; $subject = $_POST['subject'];
$message = wordwrap($_POST['message'], 70); $message = wordwrap($_POST['message'], 70);
if(!empty($message)) if (!empty($message)) {
{
$mailcounter = 0; $mailcounter = 0;
$mail->Body = $message; $mail->Body = $message;
$mail->Subject = $subject; $mail->Subject = $subject;
while($row = $db->fetch_array($result)) while ($row = $db->fetch_array($result)) {
{
$mail->AddAddress($row['email'], (isset($row['firstname']) ? $row['firstname'] . ' ' : '') . $row['name']); $mail->AddAddress($row['email'], (isset($row['firstname']) ? $row['firstname'] . ' ' : '') . $row['name']);
$mail->From = $userinfo['email']; $mail->From = $userinfo['email'];
$mail->FromName = (isset($userinfo['firstname']) ? $userinfo['firstname'] . ' ' : '') . $userinfo['name']; $mail->FromName = (isset($userinfo['firstname']) ? $userinfo['firstname'] . ' ' : '') . $userinfo['name'];
if(!$mail->Send()) if (!$mail->Send()) {
{ if ($mail->ErrorInfo != '') {
if($mail->ErrorInfo != '')
{
$mailerr_msg = $mail->ErrorInfo; $mailerr_msg = $mail->ErrorInfo;
} } else {
else $mailerr_msg = $row['email'];
{
$mailerr_msg = $row["email"];
} }
$log->logAction(ADM_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg); $log->logAction(ADM_ACTION, LOG_ERR, 'Error sending mail: ' . $mailerr_msg);
standard_error('errorsendingmail', $row["email"]); standard_error('errorsendingmail', $row['email']);
} }
$mailcounter++; $mailcounter++;
@@ -102,47 +83,34 @@ if($page == 'message')
} }
redirectTo($filename, Array('page' => $page, 's' => $s, 'action' => 'showsuccess', 'sentitems' => $mailcounter)); redirectTo($filename, Array('page' => $page, 's' => $s, 'action' => 'showsuccess', 'sentitems' => $mailcounter));
} } else {
else
{
standard_error('nomessagetosend'); standard_error('nomessagetosend');
} }
} }
} }
if($action == 'showsuccess') if ($action == 'showsuccess') {
{
$success = 1; $success = 1;
$sentitems = isset($_GET['sentitems']) ? (int)$_GET['sentitems'] : 0; $sentitems = isset($_GET['sentitems']) ? (int)$_GET['sentitems'] : 0;
if($sentitems == 0) if ($sentitems == 0) {
{
$successmessage = $lng['message']['noreceipients']; $successmessage = $lng['message']['noreceipients'];
} } else {
else
{
$successmessage = str_replace('%s', $sentitems, $lng['message']['success']); $successmessage = str_replace('%s', $sentitems, $lng['message']['success']);
} }
} else {
$action = '';
}
else
{
$success = 0; $success = 0;
$sentitems = 0; $sentitems = 0;
$successmessage = ''; $successmessage = '';
$action = '';
} }
$action = '';
$receipients = ''; $receipients = '';
if($userinfo['customers_see_all'] == "1") if ($userinfo['customers_see_all'] == '1') {
{
$receipients.= makeoption($lng['panel']['reseller'], 0); $receipients.= makeoption($lng['panel']['reseller'], 0);
} }
$receipients.= makeoption($lng['panel']['customer'], 1); $receipients .= makeoption($lng['panel']['customer'], 1);
eval("echo \"" . getTemplate("message/message") . "\";"); eval("echo \"" . getTemplate('message/message') . "\";");
} }
?>