[ Index ] |
|
Code source de Horde 3.1.3 |
1 <?php 2 /** 3 * $Horde: horde/services/problem.php,v 2.114.8.8 2006/01/16 14:24:03 chuck Exp $ 4 * 5 * Copyright 1999-2006 Charles J. Hagenbuch <chuck@horde.org> 6 * Copyright 1999-2006 Jon Parise <jon@horde.org> 7 * 8 * See the enclosed file COPYING for license information (LGPL). If you 9 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. 10 */ 11 12 /* Send the browser back to the correct page. */ 13 function _returnToPage() 14 { 15 $url = Util::getFormData('return_url', Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/login.php', true)); 16 header('Location: ' . str_replace('&', '&', $url)); 17 exit; 18 } 19 20 @define('AUTH_HANDLER', true); 21 @define('HORDE_BASE', dirname(__FILE__) . '/..'); 22 require_once HORDE_BASE . '/lib/base.php'; 23 require_once HORDE_BASE . '/lib/version.php'; 24 require_once 'Horde/Identity.php'; 25 26 if (!Horde::showService('problem')) { 27 _returnToPage(); 28 } 29 30 $identity = &Identity::singleton(); 31 $email = $identity->getValue('from_addr'); 32 if (!$email) { 33 $email = Util::getFormData('email', Auth::getAuth()); 34 } 35 $message = Util::getFormData('message', ''); 36 $name = Util::getFormData('name', $identity->getValue('fullname')); 37 $subject = Util::getFormData('subject', ''); 38 39 $actionID = Util::getFormData('actionID'); 40 switch ($actionID) { 41 case 'send_problem_report': 42 if ($subject && $message) { 43 // This is not a gettext string on purpose. 44 $remote = (!empty($_SERVER['REMOTE_HOST'])) ? $_SERVER['REMOTE_HOST'] : $_SERVER['REMOTE_ADDR']; 45 $user_agent = $_SERVER['HTTP_USER_AGENT']; 46 $body = "This problem report was received from $remote. " . 47 "The user clicked the problem report link from the following location:\n" . 48 Util::getFormData('return_url', 'No requesting page') . 49 "\nand is using the following browser:\n$user_agent\n\n" . 50 str_replace("\r\n", "\n", $message); 51 52 // Default to a relatively reasonable email address. 53 if (!$email) { 54 $email = 'horde-problem@' . $conf['problems']['maildomain']; 55 } 56 57 if (!empty($conf['problems']['tickets']) && 58 $registry->hasMethod('tickets/addTicket')) { 59 $info = array_merge($conf['problems']['ticket_params'], 60 array('summary' => $subject, 61 'comment' => $body, 62 'user_email' => $email)); 63 $result = $registry->call('tickets/addTicket', array($info)); 64 if (is_a($result, 'PEAR_Error')) { 65 $notification->push($result); 66 } else { 67 _returnToPage(); 68 } 69 } else { 70 require_once 'Horde/MIME.php'; 71 require_once 'Horde/MIME/Headers.php'; 72 require_once 'Horde/MIME/Message.php'; 73 74 // Add user's name to the email address if provided. 75 if ($name) { 76 @list($mailbox, $host) = @explode('@', $email, 2); 77 if (empty($host)) { 78 $host = $conf['problems']['maildomain']; 79 } 80 $email = MIME::rfc822WriteAddress($mailbox, $host, $name); 81 } 82 83 $msg_headers = &new MIME_Headers(); 84 $msg_headers->addReceivedHeader(); 85 $msg_headers->addMessageIdHeader(); 86 $msg_headers->addAgentHeader(); 87 $msg_headers->addHeader('Date', date('r')); 88 $msg_headers->addHeader('To', $conf['problems']['email']); 89 $msg_headers->addHeader('Subject', _("[Problem Report]") . ' ' . $subject); 90 $msg_headers->addHeader('From', $email); 91 $msg_headers->addHeader('Sender', 'horde-problem@' . $conf['problems']['maildomain']); 92 93 $mime = &new MIME_Message(); 94 $mime->addPart(new MIME_Part('text/plain', 95 String::wrap($body, 80, "\n"), 96 NLS::getCharset())); 97 $msg_headers->addMIMEHeaders($mime); 98 99 $mail_driver = $conf['mailer']['type']; 100 $mail_params = $conf['mailer']['params']; 101 if ($mail_driver == 'smtp' && $mail_params['auth'] && 102 empty($mail_params['username'])) { 103 if (Auth::getAuth()) { 104 $mail_params['username'] = Auth::getAuth(); 105 $mail_params['password'] = Auth::getCredential('password'); 106 } elseif (!empty($conf['problems']['username']) && 107 !empty($conf['problems']['password'])) { 108 $mail_params['username'] = $conf['problems']['username']; 109 $mail_params['password'] = $conf['problems']['password']; 110 } 111 } 112 113 if (!is_a($sent = $mime->send($conf['problems']['email'], $msg_headers, $mail_driver, $mail_params), 'PEAR_Error')) { 114 /* We succeeded. Return to previous page and exit this script. */ 115 _returnToPage(); 116 } else { 117 $notification->push($sent); 118 } 119 } 120 } 121 break; 122 123 case 'cancel_problem_report': 124 _returnToPage(); 125 } 126 127 $title = _("Problem Description"); 128 $menu = &new Menu(HORDE_MENU_MASK_ALL & ~HORDE_MENU_MASK_PREFS); 129 require HORDE_TEMPLATES . '/common-header.inc'; 130 require HORDE_TEMPLATES . '/menu/menu.inc'; 131 $notification->notify(array('listeners' => 'status')); 132 require HORDE_TEMPLATES . '/problem/problem.inc'; 133 require HORDE_TEMPLATES . '/common-footer.inc';
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 18:01:28 2007 | par Balluche grâce à PHPXref 0.7 |