File: problem.php

package info (click to toggle)
horde2 2.2.8-1sarge3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,832 kB
  • ctags: 2,897
  • sloc: php: 12,784; sh: 954; sql: 149; makefile: 104; perl: 97; xml: 24; pascal: 6
file content (118 lines) | stat: -rw-r--r-- 4,549 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
/**
 * $Horde: horde/problem.php,v 2.62.2.16 2005/01/03 11:25:45 jan Exp $
 *
 * Copyright 1999-2005 Charles J. Hagenbuch <chuck@horde.org>
 * Copyright 1999-2005 Jon Parise <jon@horde.org>
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 */

/* Send the browser back to the correct page. */
function returnToPage() {
    $returnURL = Horde::getFormData('return_url', 'login.php');
    header('Location: ' . str_replace('&amp;', '&', $returnURL));
}

define('HORDE_BASE', dirname(__FILE__));
require_once HORDE_BASE . '/lib/base.php';
require_once HORDE_BASE . '/lib/Identity.php';
require_once HORDE_BASE . '/lib/version.php';

if (!Auth::getAuth()) {
    returnToPage();
}

$identity = new Identity();
$name = Horde::getFormData('name', $identity->getValue('fullname'));
$email = Horde::getFormData('email', $identity->getValue('from_addr'));
$subject = Horde::getFormData('subject', '');
$message = Horde::getFormData('message', '');

/* Run through action handlers */
$actionID = Horde::getFormData('actionID');
switch ($actionID) {
 case HORDE_SEND_PROBLEM_REPORT:
     include_once HORDE_BASE . '/lib/Text.php';

     if (!empty($subject) && !empty($message)) {
         include_once HORDE_BASE . '/lib/MIME.php';
         include_once HORDE_BASE . '/lib/MIME/Message.php';

         // add a Received header for the hop from browser to server.
         $remote = (!empty($_SERVER['REMOTE_HOST'])) ? $_SERVER['REMOTE_HOST'] : $_SERVER['REMOTE_ADDR'];
         $user_agent = $_SERVER['HTTP_USER_AGENT'];
         $headers['Received'] = 'from ' . $remote . ' (';
         if (!empty($_SERVER['REMOTE_IDENT'])) $headers['Received'] .= $_SERVER['REMOTE_IDENT'] . '@' . $remote;
         $headers['Received'] .= ' [' . $remote . '])';
         $headers['Received'] .= "\n\t by " . $registry->getParam('server_name') . ' with HTTP;';
         $headers['Received'] .= "\n\t" . date('r');

         $headers['Message-ID'] = '<' . uniqid(time() . '.') . '@' . $registry->getParam('server_name') . '>';
         $headers['Date'] = date('r');
         $headers['To'] = $conf['problems']['email'];
         if (!empty($email)) {
             if (!empty($name)) {
                 // FIXME: need Mail_RFC822::writeAddress() here
                 $headers['From'] = '"' . addslashes($name) . '" <' . $email . '>';
             } else {
                 $headers['From'] = $email;
             }
             $headers['Sender'] = 'horde-problem@' . $registry->getParam('server_name');
         } else {
             $headers['From'] = 'horde-problem@' . $registry->getParam('server_name');
         }
         $recipients = $conf['problems']['email'];
         $headers['Subject'] = _("[Problem Report]") . ' ' . $subject;
         $headers['User-Agent'] = 'Horde ' . HORDE_VERSION;

         $message = str_replace("\r\n", "\n", $message);

         // This is not a gettext string on purpose.
         $message = "This problem report was received from $remote. " .
             "The user clicked the problem report link from the following location:\n" .
             Horde::getFormData('return_url', 'No requesting page') .
             "\nand is using the following browser:\n$user_agent\n\n$message";

         $mime = new MIME_Message();
         $body = new MIME_Part('text/plain', Text::wrap($message, 80, "\n"));

         $mime->addPart($body);
         $headers = $mime->header($headers);
         $msg = $mime->toString();

         include_once 'Mail.php';
         $mailer = &Mail::factory($conf['mailer']['type'], $conf['mailer']['params']);
         if (!PEAR::isError($mailer->send($recipients, $headers, $msg))) {
             /* We succeeded. Return to previous page and exit this script. */
             returnToPage();
             exit;
         } else {
             $label = _("Describe the Problem");
         }
     } else {
         /* Something wasn't quite right. Strange. */
         $label = _("Describe the Problem");
     }
     break;

 case HORDE_CANCEL_PROBLEM_REPORT:
     returnToPage();
     exit;
     break;
}

if (empty($label)) {
    $label = _("Describe the Problem");
}

$title = _("Problem Description");
$js_onLoad = null;
require HORDE_TEMPLATES . '/common-header.inc';
require HORDE_BASE . '/navbar.php';
require HORDE_TEMPLATES . '/problem/problem.inc';
if ($browser->hasFeature('javascript')) {
    include HORDE_TEMPLATES . '/problem/javascript.inc';
}
require HORDE_TEMPLATES . '/common-footer.inc';