/** * Send multiple emails using this simple tool * * @param void * @return null */ function tool_mass_mailer() { $tool = AdministrationTools::getByName('mass_mailer'); if (!$tool instanceof AdministrationTool) { flash_error(lang('administration tool dnx', 'test_mail_settings')); $this->redirectTo('administration', 'tools'); } // if $massmailer_data = array_var($_POST, 'massmailer'); tpl_assign('tool', $tool); tpl_assign('grouped_users', Users::getGroupedByCompany()); tpl_assign('massmailer_data', $massmailer_data); if (is_array($massmailer_data)) { try { $subject = trim(array_var($massmailer_data, 'subject')); $message = trim(array_var($massmailer_data, 'message')); $errors = array(); if ($subject == '') { $errors[] = lang('massmailer subject required'); } // if if ($message == '') { $errors[] = lang('massmailer message required'); } // if $users = Users::getAll(); $recipients = array(); if (is_array($users)) { foreach ($users as $user) { if (array_var($massmailer_data, 'user_' . $user->getId()) == 'checked') { $recipients[] = Notifier::prepareEmailAddress($user->getEmail(), $user->getDisplayName()); } // if } // foreach } // if if (!count($recipients)) { $errors[] = lang('massmailer select recipients'); } // if if (count($errors)) { throw new FormSubmissionErrors($errors); } // if if (Notifier::sendEmail($recipients, Notifier::prepareEmailAddress(logged_user()->getEmail(), logged_user()->getDisplayName()), $subject, $message)) { flash_success(lang('success massmail')); } else { flash_error(lang('error massmail')); } // if $this->redirectToUrl($tool->getToolUrl()); } catch (Exception $e) { tpl_assign('error', $e); } // try } // if }
/** * Render and execute test mailer form * * @param void * @return null */ function tool_test_email() { set_time_limit(0); if (!can_manage_configuration(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } // if $tool = AdministrationTools::getByName('test_mail_settings'); if (!$tool instanceof AdministrationTool) { flash_error(lang('administration tool dnx', 'test_mail_settings')); $this->redirectTo('administration', 'tools'); } // if $test_mail_data = array_var($_POST, 'test_mail'); tpl_assign('tool', $tool); tpl_assign('test_mail_data', $test_mail_data); if (is_array($test_mail_data)) { try { $recepient = trim(array_var($test_mail_data, 'recepient')); $message = trim(array_var($test_mail_data, 'message')); $errors = array(); if ($recepient == '') { $errors[] = lang('test mail recipient required'); } else { if (!is_valid_email($recepient)) { $errors[] = lang('test mail recipient invalid format'); } // if } // if if ($message == '') { $errors[] = lang('test mail message required'); } // if if (count($errors)) { throw new FormSubmissionErrors($errors); } // if $to = array($recepient); $success = Notifier::sendEmail($to, logged_user()->getEmailAddress(), lang('test mail message subject'), $message); if ($success) { flash_success(lang('success test mail settings')); } else { flash_error(lang('error test mail settings')); } // if ajx_current("back"); } catch (Exception $e) { flash_error($e->getMessage()); ajx_current("empty"); } // try } // if }
function browse_log() { trace(__FILE__, 'browse_log()'); $tool = AdministrationTools::getByName('browse_log'); if (!$tool instanceof AdministrationTool) { flash_error(lang('administration tool dnx', 'browse_log')); $this->redirectTo('administration', 'tools'); } // if tpl_assign('tool', $tool); $pos = isset($_GET['pos']) ? 0 + $_GET['pos'] : -1; $dir = isset($_GET['dir']) ? $_GET['dir'] : 'up'; $lines = array(); $handle = @fopen("cache/log.php", "r"); //$handle = fopen("AdministrationController.class.php", "r"); if ($handle) { if ($pos < 0) { fseek($handle, 0, SEEK_END); // Seek to the end $pos = ftell($handle); } $pos = $dir == 'up' ? $pos - 4096 : $pos; fseek($handle, $pos, SEEK_SET); // Seek to the position $lines = explode("\n", fread($handle, 4096)); $pos = ftell($handle); fclose($handle); } //$lines = array( "aaaaa", "bbbbbb" ); tpl_assign('pos', $pos); tpl_assign('lines', $lines); }