[ Index ]

PHP Cross Reference of MyBB

title

Body

[close]

/admin/modules/tools/ -> mailerrors.php (source)

   1  <?php
   2  /**
   3   * MyBB 1.6
   4   * Copyright 2010 MyBB Group, All Rights Reserved
   5   *
   6   * Website: http://mybb.com
   7   * License: http://mybb.com/about/license
   8   *
   9   * $Id$
  10   */
  11  
  12  // Disallow direct access to this file for security reasons
  13  if(!defined("IN_MYBB"))
  14  {
  15      die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
  16  }
  17  
  18  $page->add_breadcrumb_item($lang->system_email_log, "index.php?module=tools-mailerrors");
  19  
  20  $plugins->run_hooks("admin_tools_mailerrors_begin");
  21  
  22  if($mybb->input['action'] == "prune" && $mybb->request_method == "post")
  23  {
  24      $plugins->run_hooks("admin_tools_mailerrors_prune");
  25  
  26      if($mybb->input['delete_all'])
  27      {
  28          $db->delete_query("mailerrors");
  29          $num_deleted = $db->affected_rows();
  30  
  31          $plugins->run_hooks("admin_tools_mailerrors_prune_delete_all_commit");
  32  
  33          // Log admin action
  34          log_admin_action($num_deleted);
  35  
  36          flash_message($lang->all_logs_deleted, 'success');
  37          admin_redirect("index.php?module=tools-mailerrors");
  38      }
  39      else if(is_array($mybb->input['log']))
  40      {
  41          $log_ids = implode(",", array_map("intval", $mybb->input['log']));
  42          if($log_ids)
  43          {
  44              $db->delete_query("mailerrors", "eid IN ({$log_ids})");
  45              $num_deleted = $db->affected_rows();
  46          }
  47      }
  48  
  49      $plugins->run_hooks("admin_tools_mailerrors_prune_commit");
  50  
  51      // Log admin action
  52      log_admin_action($num_deleted);
  53  
  54      flash_message($lang->selected_logs_deleted, 'success');
  55      admin_redirect("index.php?module=tools-mailerrors");
  56  }
  57  
  58  if($mybb->input['action'] == "view")
  59  {
  60      $plugins->run_hooks("admin_tools_mailerrors_view");
  61  
  62      $query = $db->simple_select("mailerrors", "*", "eid='".intval($mybb->input['eid'])."'");
  63      $log = $db->fetch_array($query);
  64  
  65      if(!$log['eid'])
  66      {
  67          exit;
  68      }
  69  
  70      $log['toaddress'] = htmlspecialchars_uni($log['toaddress']);
  71      $log['fromaddress'] = htmlspecialchars_uni($log['fromaddress']);
  72      $log['subject'] = htmlspecialchars_uni($log['subject']);
  73      $log['error'] = htmlspecialchars_uni($log['error']);
  74      $log['smtperror'] = htmlspecialchars_uni($log['smtpcode']);
  75      $log['dateline'] = date($mybb->settings['dateformat'], $log['dateline']).", ".date($mybb->settings['timeformat'], $log['dateline']);
  76      $log['message'] = nl2br(htmlspecialchars_uni($log['message']));
  77  
  78      ?>
  79  <html xmlns="http://www.w3.org/1999/xhtml">
  80  <head profile="http://gmpg.org/xfn/1">
  81      <title><?php echo $lang->user_email_log_viewer; ?></title>
  82      <link rel="stylesheet" href="styles/<?php echo $page->style; ?>/main.css" type="text/css" />
  83      <link rel="stylesheet" href="styles/<?php echo $page->style; ?>/popup.css" type="text/css" />
  84  </head>
  85  <body id="popup">
  86      <div id="popup_container">
  87      <div class="popup_title"><a href="#" onClick="window.close();" class="close_link"><?php echo $lang->close_window; ?></a><?php echo $lang->user_email_log_viewer; ?></div>
  88  
  89      <div id="content">
  90      <?php
  91      $table = new Table();
  92  
  93      $table->construct_cell($log['error'], array("colspan" => 2));
  94      $table->construct_row();
  95  
  96      if($log['smtpcode'])
  97      {
  98          $table->construct_cell($lang->smtp_code);
  99          $table->construct_cell($log['smtpcode']);
 100          $table->construct_row();
 101      }
 102  
 103      if($log['smtperror'])
 104      {
 105          $table->construct_cell($lang->smtp_server_response);
 106          $table->construct_cell($log['smtperror']);
 107          $table->construct_row();
 108      }
 109      $table->output($lang->error);
 110  
 111      $table = new Table();
 112  
 113      $table->construct_cell($lang->to.":");
 114      $table->construct_cell("<a href=\"mailto:{$log['toaddress']}\">{$log['toaddress']}</a>");
 115      $table->construct_row();
 116  
 117      $table->construct_cell($lang->from.":");
 118      $table->construct_cell("<a href=\"mailto:{$log['fromaddress']}\">{$log['fromaddress']}</a>");
 119      $table->construct_row();
 120  
 121      $table->construct_cell($lang->subject.":");
 122      $table->construct_cell($log['subject']);
 123      $table->construct_row();
 124  
 125      $table->construct_cell($lang->date.":");
 126      $table->construct_cell($log['dateline']);
 127      $table->construct_row();
 128  
 129      $table->construct_cell($log['message'], array("colspan" => 2));
 130      $table->construct_row();
 131  
 132      $table->output($lang->email);
 133  
 134      ?>
 135      </div>
 136  </div>
 137  </body>
 138  </html>
 139      <?php
 140  }
 141  
 142  if(!$mybb->input['action'])
 143  {
 144      $plugins->run_hooks("admin_tools_mailerrors_start");
 145  
 146      $per_page = 20;
 147  
 148      if($mybb->input['page'] && $mybb->input['page'] > 1)
 149      {
 150          $mybb->input['page'] = intval($mybb->input['page']);
 151          $start = ($mybb->input['page']*$per_page)-$per_page;
 152      }
 153      else
 154      {
 155          $mybb->input['page'] = 1;
 156          $start = 0;
 157      }
 158  
 159      $additional_criteria = array();
 160  
 161      $page->output_header($lang->system_email_log);
 162  
 163      $sub_tabs['mailerrors'] = array(
 164          'title' => $lang->system_email_log,
 165          'link' => "index.php?module=tools-mailerrors",
 166          'description' => $lang->system_email_log_desc
 167      );
 168  
 169      $page->output_nav_tabs($sub_tabs, 'mailerrors');
 170  
 171      $form = new Form("index.php?module=tools-mailerrors&amp;action=prune", "post");
 172  
 173      // Begin criteria filtering
 174      if($mybb->input['subject'])
 175      {
 176          $additional_sql_criteria .= " AND subject LIKE '%".$db->escape_string_like($mybb->input['subject'])."%'";
 177          $additional_criteria[] = "subject='".htmlspecialchars_uni($mybb->input['subject'])."'";
 178          $form->generate_hidden_field("subject", $mybb->input['subject']);
 179      }
 180  
 181      if($mybb->input['fromaddress'])
 182      {
 183          $additional_sql_criteria .= " AND fromaddress LIKE '%".$db->escape_string_like($mybb->input['fromaddress'])."%'";
 184          $additional_criteria[] = "fromaddress='".urlencode($mybb->input['fromaddress'])."'";
 185          $form->generate_hidden_field("fromaddress", $mybb->input['fromaddress']);
 186      }
 187  
 188      if($mybb->input['toaddress'])
 189      {
 190          $additional_sql_criteria .= " AND toaddress LIKE '%".$db->escape_string_like($mybb->input['toaddress'])."%'";
 191          $additional_criteria[] = "toaddress='".urlencode($mybb->input['toaddress'])."'";
 192          $form->generate_hidden_field("toaddress", $mybb->input['toaddress']);
 193      }
 194  
 195      if($mybb->input['error'])
 196      {
 197          $additional_sql_criteria .= " AND error LIKE '%".$db->escape_string_like($mybb->input['error'])."%'";
 198          $additional_criteria[] = "error='".urlencode($mybb->input['error'])."'";
 199          $form->generate_hidden_field("error", $mybb->input['error']);
 200      }
 201  
 202      if($additional_criteria)
 203      {
 204          $additional_criteria = "&amp;".implode("&amp;", $additional_criteria);
 205      }
 206  
 207      $table = new Table;
 208      $table->construct_header($form->generate_check_box("checkall", 1, '', array('class' => 'checkall')));
 209      $table->construct_header($lang->subject);
 210      $table->construct_header($lang->to, array("class" => "align_center", "width" => "20%"));
 211      $table->construct_header($lang->error_message, array("class" => "align_center", "width" => "30%"));
 212      $table->construct_header($lang->date_sent, array("class" => "align_center", "width" => "20%"));
 213  
 214      $query = $db->query("
 215          SELECT *
 216          FROM ".TABLE_PREFIX."mailerrors
 217          WHERE 1=1 {$additional_sql_criteria}
 218          ORDER BY dateline DESC
 219          LIMIT {$start}, {$per_page}
 220      ");
 221      while($log = $db->fetch_array($query))
 222      {
 223          $log['subject'] = htmlspecialchars_uni($log['subject']);
 224          $log['toemail'] = htmlspecialchars_uni($log['toemail']);
 225          $log['error'] = htmlspecialchars_uni($log['error']);
 226          $log['dateline'] = date($mybb->settings['dateformat'], $log['dateline']).", ".date($mybb->settings['timeformat'], $log['dateline']);
 227  
 228          $table->construct_cell($form->generate_check_box("log[{$log['eid']}]", $log['eid'], ''));
 229          $table->construct_cell("<a href=\"javascript:MyBB.popupWindow('index.php?module=tools-mailerrors&amp;action=view&amp;eid={$log['eid']}', 'log_entry', 450, 450);\">{$log['subject']}</a>");
 230          $find_from = "<div class=\"float_right\"><a href=\"index.php?module=tools-mailerrors&amp;toaddress={$log['toaddress']}\"><img src=\"styles/{$page->style}/images/icons/find.gif\" title=\"{$lang->fine_emails_to_addr}\" alt=\"{$lang->find}\" /></a></div>";
 231          $table->construct_cell("{$find_from}<div>{$log['toaddress']}</div>");
 232          $table->construct_cell($log['error']);
 233          $table->construct_cell($log['dateline'], array("class" => "align_center"));
 234          $table->construct_row();
 235      }
 236  
 237      if($table->num_rows() == 0)
 238      {
 239          $table->construct_cell($lang->no_logs, array("colspan" => 5));
 240          $table->construct_row();
 241          $table->output($lang->system_email_log);
 242      }
 243      else
 244      {
 245          $table->output($lang->system_email_log);
 246          $buttons[] = $form->generate_submit_button($lang->delete_selected, array('onclick' => "return confirm('{$lang->confirm_delete_logs}');"));
 247          $buttons[] = $form->generate_submit_button($lang->delete_all, array('name' => 'delete_all', 'onclick' => "return confirm('{$lang->confirm_delete_all_logs}');"));
 248          $form->output_submit_wrapper($buttons);
 249      }
 250  
 251      $form->end();
 252  
 253      $query = $db->simple_select("mailerrors l", "COUNT(eid) AS logs", "1=1 {$additional_sql_criteria}");
 254      $total_rows = $db->fetch_field($query, "logs");
 255  
 256      echo "<br />".draw_admin_pagination($mybb->input['page'], $per_page, $total_rows, "index.php?module=tools-mailerrors&amp;page={page}{$additional_criteria}");
 257  
 258      $form = new Form("index.php?module=tools-mailerrors", "post");
 259      $form_container = new FormContainer($lang->filter_system_email_log);
 260      $form_container->output_row($lang->subject_contains, "", $form->generate_text_box('subject', $mybb->input['subject'], array('id' => 'subject')), 'subject');
 261      $form_container->output_row($lang->error_message_contains, "", $form->generate_text_box('error', $mybb->input['error'], array('id' => 'error')), 'error');
 262      $form_container->output_row($lang->to_address_contains, "", $form->generate_text_box('toaddress', $mybb->input['toaddress'], array('id' => 'toaddress')), 'toaddress');
 263      $form_container->output_row($lang->from_address_contains, "", $form->generate_text_box('fromaddress', $mybb->input['fromaddress'], array('id' => 'fromaddress')), 'fromaddress');
 264  
 265      $form_container->end();
 266      $buttons = array();
 267      $buttons[] = $form->generate_submit_button($lang->filter_system_email_log);
 268      $form->output_submit_wrapper($buttons);
 269      $form->end();
 270  
 271      $page->output_footer();
 272  }
 273  ?>


Generated: Tue Oct 8 19:19:50 2013 Cross-referenced by PHPXref 0.7.1