[ Index ]

PHP Cross Reference of MyBB 1.8.38

title

Body

[close]

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

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


2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup Cross-referenced by PHPXref