From 54fc4758d923f8b582a2cdddabbe5bbade8db351 Mon Sep 17 00:00:00 2001 From: Axel Guckelsberger Date: Sat, 27 Apr 2013 10:56:34 +0300 Subject: [PATCH] Update admin_message.php --- admin_message.php | 104 ++++++++++++++++------------------------------ 1 file changed, 36 insertions(+), 68 deletions(-) diff --git a/admin_message.php b/admin_message.php index a0e67613..c50c7290 100644 --- a/admin_message.php +++ b/admin_message.php @@ -22,79 +22,60 @@ define('AREA', 'admin'); /** * 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']); -} -elseif(isset($_GET['id'])) -{ +} elseif (isset($_GET['id'])) { $id = intval($_GET['id']); } -if($page == 'message') -{ - if($action == '') - { - $log->logAction(ADM_ACTION, LOG_NOTICE, "viewed panel_message"); +if ($page == 'message') { + if ($action == '') { + $log->logAction(ADM_ACTION, LOG_NOTICE, 'viewed panel_message'); - if(isset($_POST['send']) - && $_POST['send'] == 'send') - { - if($_POST['receipient'] == 0 - && $userinfo['customers_see_all'] == '1') - { - $log->logAction(ADM_ACTION, LOG_NOTICE, "sending messages to admins"); + if (isset($_POST['send']) + && $_POST['send'] == 'send' + ) { + if ($_POST['receipient'] == 0 + && $userinfo['customers_see_all'] == '1' + ) { + $log->logAction(ADM_ACTION, LOG_NOTICE, 'sending messages to admins'); $result = $db->query('SELECT `name`, `email` FROM `' . TABLE_PANEL_ADMINS . "`"); - } - elseif($_POST['receipient'] == 1) - { - if($userinfo['customers_see_all'] == "1") - { - $log->logAction(ADM_ACTION, LOG_NOTICE, "sending messages to ALL customers"); + } elseif ($_POST['receipient'] == 1) { + 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 . "`"); - } - else - { - $log->logAction(ADM_ACTION, LOG_NOTICE, "sending messages to customers"); + } else { + $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'] . "'"); } - } - else - { + } else { standard_error('noreceipientsgiven'); } $subject = $_POST['subject']; $message = wordwrap($_POST['message'], 70); - if(!empty($message)) - { + if (!empty($message)) { $mailcounter = 0; $mail->Body = $message; $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->From = $userinfo['email']; $mail->FromName = (isset($userinfo['firstname']) ? $userinfo['firstname'] . ' ' : '') . $userinfo['name']; - if(!$mail->Send()) - { - if($mail->ErrorInfo != '') - { + if (!$mail->Send()) { + if ($mail->ErrorInfo != '') { $mailerr_msg = $mail->ErrorInfo; - } - else - { - $mailerr_msg = $row["email"]; + } else { + $mailerr_msg = $row['email']; } - $log->logAction(ADM_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg); - standard_error('errorsendingmail', $row["email"]); + $log->logAction(ADM_ACTION, LOG_ERR, 'Error sending mail: ' . $mailerr_msg); + standard_error('errorsendingmail', $row['email']); } $mailcounter++; @@ -102,47 +83,34 @@ if($page == 'message') } redirectTo($filename, Array('page' => $page, 's' => $s, 'action' => 'showsuccess', 'sentitems' => $mailcounter)); - } - else - { + } else { standard_error('nomessagetosend'); } } } - if($action == 'showsuccess') - { + if ($action == 'showsuccess') { $success = 1; $sentitems = isset($_GET['sentitems']) ? (int)$_GET['sentitems'] : 0; - if($sentitems == 0) - { + if ($sentitems == 0) { $successmessage = $lng['message']['noreceipients']; - } - else - { + } else { $successmessage = str_replace('%s', $sentitems, $lng['message']['success']); } - - $action = ''; - } - else - { + } else { $success = 0; $sentitems = 0; $successmessage = ''; - $action = ''; } + $action = ''; $receipients = ''; - if($userinfo['customers_see_all'] == "1") - { + if ($userinfo['customers_see_all'] == '1') { $receipients.= makeoption($lng['panel']['reseller'], 0); } - $receipients.= makeoption($lng['panel']['customer'], 1); - eval("echo \"" . getTemplate("message/message") . "\";"); + $receipients .= makeoption($lng['panel']['customer'], 1); + eval("echo \"" . getTemplate('message/message') . "\";"); } - -?>