diff -r 000000000000 -r cda2c95b368d AdminReport.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/AdminReport.php Fri Jul 30 23:35:44 2010 -0400 @@ -0,0 +1,200 @@ +attachHook('session_started', 'register_special_page(\'AdminReport\', \'Report site bug\', true);'); + +function page_Special_AdminReport() +{ + global $db, $session, $paths, $template, $plugins; // Common objects + global $output; + + // parse parameters + $parms = str_replace('_', ' ', dirtify_page_id($paths->getAllParams())); + $replaces = array(); + if ( preg_match_all('/<(.+?)>/', $parms, $matches) ) + { + foreach ( $matches[0] as $i => $match ) + { + $replaces[] = $matches[1][$i]; + $parms = str_replace_once($match, "\${$i}\$", $parms); + } + } + + $parms = explode('/', $parms); + $info = array( + 'page' => '', + 'comment' => '' + ); + foreach ( $parms as $parm ) + { + list($name) = explode('=', $parm); + $info[$name] = substr($parm, strlen($name)+1); + foreach ( $replaces as $i => $val ) + { + $info[$name] = str_replace_once("\${$i}\$", $val, $info[$name]); + } + } + + $output->header(); + + $errors = array(); + if ( isset($_POST['submit']) ) + { + $page = $_POST['page']; + $comment = trim($_POST['comment']); + $captcha_input = $_POST['captcha_response']; + $captcha_id = $_POST['captcha_id']; + if ( strtolower($captcha_input) !== ($correct = strtolower($session->get_captcha($captcha_id))) ) + { + $errors[] = 'The confirmation code you entered was incorrect. '; // . "($captcha_input vs. $correct)"; + } + $session->kill_captcha(); + if ( empty($comment) ) + { + $errors[] = 'Please enter a description of the problem.'; + } + else + { + $info['comment'] = $comment; + } + + if ( empty($errors) ) + { + $email = getConfig('contact_email'); + + if ( !is_array($result = arp_send_mail($email, "[{$_SERVER['HTTP_HOST']}] Website bug report", "Sent from IP: {$_SERVER['REMOTE_ADDR']}\n\n---------------------------\n$comment)")) ) + { + redirect(makeUrl($page), 'Report sent', 'Thank you, your report has been sent. Redirecting you back to the page...', 5); + } + else + { + $errors = $result; + } + } + + $info['page'] = $_POST['page']; + } + + $captchacode = $session->make_captcha(); + if ( !empty($errors) ) + { + echo '