AdminReport.php
author Dan Fuhry <dan@enanocms.org>
Fri, 30 Jul 2010 23:35:44 -0400
changeset 0 cda2c95b368d
child 1 13ac3d9d47b2
permissions -rw-r--r--
First commit
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
     1
<?php
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
     2
/**!info**
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
     3
{
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
     4
  "Plugin Name"  : "Admin report generator",
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
     5
  "Plugin URI"   : "http://enanocms.org/plugin/adminreport",
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
     6
  "Description"  : "Allow users to report bugs with the site, including with automatic links that fill everything in.",
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
     7
  "Author"       : "Dan Fuhry",
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
     8
  "Version"      : "1.0",
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
     9
  "Author URI"   : "http://enanocms.org/"
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    10
}
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    11
**!*/
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    12
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    13
$plugins->attachHook('session_started', 'register_special_page(\'AdminReport\', \'Report site bug\', true);');
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    14
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    15
function page_Special_AdminReport()
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    16
{
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    17
	global $db, $session, $paths, $template, $plugins; // Common objects
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    18
	global $output;
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    19
	
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    20
	// parse parameters
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    21
	$parms = str_replace('_', ' ', dirtify_page_id($paths->getAllParams()));
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    22
	$replaces = array();
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    23
	if ( preg_match_all('/<(.+?)>/', $parms, $matches) )
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    24
	{
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    25
		foreach ( $matches[0] as $i => $match )
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    26
		{
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    27
			$replaces[] = $matches[1][$i];
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    28
			$parms = str_replace_once($match, "\${$i}\$", $parms);
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    29
		}
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    30
	}
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    31
	
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    32
	$parms = explode('/', $parms);
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    33
	$info = array(
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    34
			'page' => '',
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    35
			'comment' => ''
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    36
		);
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    37
	foreach ( $parms as $parm )
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    38
	{
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    39
		list($name) = explode('=', $parm);
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    40
		$info[$name] = substr($parm, strlen($name)+1);
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    41
		foreach ( $replaces as $i => $val )
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    42
		{
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    43
			$info[$name] = str_replace_once("\${$i}\$", $val, $info[$name]);
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    44
		}
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    45
	}
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    46
	
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    47
	$output->header();
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    48
	
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    49
	$errors = array();
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    50
	if ( isset($_POST['submit']) )
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    51
	{
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    52
		$page = $_POST['page'];
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    53
		$comment = trim($_POST['comment']);
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    54
		$captcha_input = $_POST['captcha_response'];
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    55
		$captcha_id = $_POST['captcha_id'];
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    56
		if ( strtolower($captcha_input) !== ($correct = strtolower($session->get_captcha($captcha_id))) )
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    57
		{
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    58
			$errors[] = 'The confirmation code you entered was incorrect. '; // . "($captcha_input vs. $correct)";
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    59
		}
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    60
		$session->kill_captcha();
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    61
		if ( empty($comment) )
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    62
		{
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    63
			$errors[] = 'Please enter a description of the problem.';
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    64
		}
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    65
		else
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    66
		{
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    67
			$info['comment'] = $comment;
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    68
		}
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    69
		
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    70
		if ( empty($errors) )
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    71
		{
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    72
			$email = getConfig('contact_email');
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    73
			
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    74
			if ( !is_array($result = arp_send_mail($email, "[{$_SERVER['HTTP_HOST']}] Website bug report", "Sent from IP: {$_SERVER['REMOTE_ADDR']}\n\n---------------------------\n$comment)")) )
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    75
			{
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    76
				redirect(makeUrl($page), 'Report sent', 'Thank you, your report has been sent. Redirecting you back to the page...', 5);
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    77
			}
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    78
			else
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    79
			{
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    80
				$errors = $result;
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    81
			}
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    82
		}
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    83
		
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    84
		$info['page'] = $_POST['page'];
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    85
	}
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    86
	
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    87
	$captchacode = $session->make_captcha();
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    88
	if ( !empty($errors) )
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    89
	{
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    90
		echo '<div class="error-box-mini"><ul><li>' .
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    91
				implode('</li><li>', $errors) .
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    92
				'</li></ul></div>';
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    93
	}
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    94
	?>
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    95
	<form method="post" action="<?php echo makeUrl($paths->page); ?>">
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    96
		<div class="tblholder">
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    97
			<table border="0" cellspacing="1" cellpadding="4">
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    98
				<tr>
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    99
					<th colspan="2">Report a site bug</th>
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   100
				</tr>
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   101
				<tr>
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   102
					<td class="row1">
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   103
						URL of page:
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   104
					</td>
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   105
					<td class="row1">
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   106
						http<?php if ( $GLOBALS['is_https'] ) echo 's'; ?>://<?php echo htmlspecialchars($_SERVER['HTTP_HOST']); 
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   107
						echo contentPath; ?><input type="text" name="page" value="<?php echo htmlspecialchars($info['page']); ?>" />
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   108
					</td>
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   109
				</tr>
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   110
				<tr>
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   111
					<td class="row2">
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   112
						The problem:
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   113
					</td>
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   114
					<td class="row2">
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   115
						<textarea name="comment" rows="10" cols="40"><?php echo htmlspecialchars($info['comment']); ?></textarea>
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   116
					</td>
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   117
				</tr>
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   118
				<tr>
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   119
					<td class="row1">
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   120
						Code from image:
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   121
					</td>
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   122
					<td class="row1">
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   123
						<img alt="CAPTCHA" src="<?php echo makeUrlNS('Special', "Captcha/$captchacode"); ?>" style="cursor: pointer;" onclick="this.src = makeUrlNS('Special', 'Captcha/<?php echo $captchacode; ?>', String(Math.floor(Math.random() * 1000000)));" /><br />
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   124
						<br />
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   125
						Code: <input name="captcha_response" type="text" size="9" /><br />
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   126
						<small>If you can't read it, click on the image to get a different one.</small>
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   127
						<input type="hidden" name="captcha_id" value="<?php echo $captchacode; ?>" />
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   128
					</td>
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   129
				</tr>
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   130
				<tr>
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   131
					<th class="subhead" colspan="2">
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   132
						<input type="submit" name="submit" value="Send report" />
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   133
					</th>
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   134
				</tr>
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   135
			</table>
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   136
		</div>
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   137
	</form>
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   138
	<?php
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   139
	
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   140
	$output->footer();
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   141
}
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   142
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   143
function arp_send_mail($to, $subject, $body)
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   144
{
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   145
	global $session;
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   146
	global $lang, $enano_config;
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   147
	
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   148
	$use_smtp = getConfig('smtp_enabled') == '1';
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   149
		
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   150
	//
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   151
	// Let's do some checking to make sure that mass mail functions
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   152
	// are working in win32 versions of php. (copied from phpBB)
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   153
	//
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   154
	if ( preg_match('/[c-z]:\\\.*/i', getenv('PATH')) && !$use_smtp)
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   155
	{
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   156
		$ini_val = ( @phpversion() >= '4.0.0' ) ? 'ini_get' : 'get_cfg_var';
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   157
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   158
		// We are running on windows, force delivery to use our smtp functions
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   159
		// since php's are broken by default
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   160
		$use_smtp = true;
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   161
		$enano_config['smtp_server'] = @$ini_val('SMTP');
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   162
	}
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   163
	
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   164
	$mail = new emailer( !empty($use_smtp) );
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   165
	
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   166
	// Validate subject/message body
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   167
	$subject = stripslashes(trim($subject));
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   168
	$message = stripslashes(trim($body));
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   169
	
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   170
	if ( empty($subject) )
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   171
		$errors[] = $lang->get('acpmm_err_need_subject');
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   172
	if ( empty($message) )
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   173
		$errors[] = $lang->get('acpmm_err_need_message');
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   174
	
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   175
	if ( sizeof($errors) < 1 )
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   176
	{
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   177
	
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   178
		$mail->from(getConfig('contact_email'));
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   179
		$mail->replyto(getConfig('contact_email'));
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   180
		$mail->set_subject($subject);
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   181
		$mail->email_address($to);
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   182
		
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   183
		// Copied/modified from phpBB
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   184
		$email_headers = 'X-AntiAbuse: Website server name - ' . $_SERVER['SERVER_NAME'] . "\n";
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   185
		$email_headers .= 'X-AntiAbuse: User_id - ' . $session->user_id . "\n";
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   186
		$email_headers .= 'X-AntiAbuse: Username - ' . $session->username . "\n";
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   187
		$email_headers .= 'X-AntiAbuse: User IP - ' . $_SERVER['REMOTE_ADDR'] . "\n";
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   188
		
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   189
		$mail->extra_headers($email_headers);
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   190
		$mail->use_template($message);
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   191
		
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   192
		// All done
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   193
		$mail->send();
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   194
		$mail->reset();
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   195
		
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   196
		return true;
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   197
	}
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   198
	
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   199
	return $errors;
cda2c95b368d First commit
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
   200
}