]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/InboundEmail/Popup.php
Release 6.4.0
[Github/sugarcrm.git] / modules / InboundEmail / Popup.php
1 <?php
2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4  * SugarCRM Community Edition is a customer relationship management program developed by
5  * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
6  * 
7  * This program is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU Affero General Public License version 3 as published by the
9  * Free Software Foundation with the addition of the following permission added
10  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11  * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
13  * 
14  * This program is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
17  * details.
18  * 
19  * You should have received a copy of the GNU Affero General Public License along with
20  * this program; if not, see http://www.gnu.org/licenses or write to the Free
21  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22  * 02110-1301 USA.
23  * 
24  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25  * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
26  * 
27  * The interactive user interfaces in modified source and object code versions
28  * of this program must display Appropriate Legal Notices, as required under
29  * Section 5 of the GNU Affero General Public License version 3.
30  * 
31  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32  * these Appropriate Legal Notices must retain the display of the "Powered by
33  * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34  * technical reasons, the Appropriate Legal Notices must display the words
35  * "Powered by SugarCRM".
36  ********************************************************************************/
37
38 /*********************************************************************************
39
40  * Description:
41  ********************************************************************************/
42 // cn: bug 6078: zlib breaks test-settings
43 $iniError = '';
44 if(ini_get('zlib.output_compression') == 1) { // ini_get() returns 1/0, not value
45         if(!ini_set('zlib.output_compression', 'Off')) { // returns False on failure
46                 $iniError = $mod_strings['ERR_INI_ZLIB'];
47         }
48 }
49
50 // hack to allow "&", "%" and "+" through a $_GET var
51 // set by ie_test_open_popup() javascript call
52 foreach($_REQUEST as $k => $v) {
53         $v = str_replace('::amp::', '&', $v);
54         $v = str_replace('::plus::', '+', $v);
55         $v = str_replace('::percent::', '%', $v);
56         $_REQUEST[$k] = $v;
57 }
58
59 if(ob_get_level() > 0) {
60         ob_end_clean();
61 }
62
63 if(ob_get_level() < 1) {
64         ob_start();
65 }
66
67
68 require_once('modules/InboundEmail/language/'.$current_language.'.lang.php');
69 global $theme;
70
71 $title                          = '';
72 $msg                            = '';
73 $tls                            = '';
74 $cert                           = '';
75 $ssl                            = '';
76 $notls                          = '';
77 $novalidate_cert        = '';
78 $useSsl                         = false;
79
80 ///////////////////////////////////////////////////////////////////////////////
81 ////    TITLES
82
83 $popupBoolean = false;
84 if (isset($_REQUEST['target']) && $_REQUEST['target'] == 'Popup') {
85         $popupBoolean = true;
86 }
87 if (isset($_REQUEST['target1']) && $_REQUEST['target1'] == 'Popup') {
88         $popupBoolean = true;
89 }
90
91 if($popupBoolean) {
92         $title = '';
93         $msg = $mod_strings['LBL_TEST_WAIT_MESSAGE'];
94 }
95
96 if(isset($_REQUEST['ssl']) && ($_REQUEST['ssl'] == "true" || $_REQUEST['ssl'] == 1)) {
97         $msg .= $mod_strings['LBL_FIND_SSL_WARN'];
98         $useSsl = true;
99 }
100
101
102 $ie                 = new InboundEmail();
103 if(!empty($_REQUEST['ie_id'])) {
104     $ie->retrieve($_REQUEST['ie_id']);
105 }
106 $ie->email_user     = $_REQUEST['email_user'];
107 $ie->server_url     = $_REQUEST['server_url'];
108 $ie->port           = $_REQUEST['port'];
109 $ie->protocol       = $_REQUEST['protocol'];
110 //Bug 23083.Special characters in email password results in IMAP authentication failure
111 if(!empty($_REQUEST['email_password'])) {
112     $ie->email_password = html_entity_decode($_REQUEST['email_password'], ENT_QUOTES);
113     $ie->email_password = str_rot13($ie->email_password);
114 }
115 $ie->mailbox        = 'INBOX';
116
117 if($popupBoolean) {
118     $msg = $ie->connectMailserver(true);
119 }
120
121 ////    END TITLES
122 ///////////////////////////////////////////////////////////////////////////////
123
124 ///////////////////////////////////////////////////////////////////////////////
125 ////    COMMON CODE
126 echo /*'
127 <HTML>
128         <HEAD>
129                 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
130                 <title>SugarCRM - Commercial Open Source CRM</title>
131                 '.SugarThemeRegistry::current()->getCSS().'
132                 <script type="text/javascript">
133                                 function setMailbox(box) {
134                                         var mb = opener.document.getElementById("mailbox");
135                                         mb.value = box;
136                                 }
137                 </script>
138
139         </HEAD>
140         <body style="margin: 10px">*/'
141         <p>
142                 <table width="100%" cellpadding="0" cellspacing="0" border="0">
143                         <tr>
144                                 <td>
145                                         '.SugarThemeRegistry::current()->getImage('h3Arrow', 'border="0"', 11, 11, ".gif", $mod_strings['LBL_POPUP_TITLE']).'
146                                 </td>
147                                 <td>
148                                         <h3>&nbsp;'.$title.'</h3>
149                                 </td>
150                         </tr>
151                         <tr>
152                                 <td></td>
153                                 <td valign="top">
154                                         <div id="testSettingsMsg">
155                                         '.$msg.'
156                                         </div>
157                                         <div id="testSettingsTic"></div>
158                                         <div id="testSettingsErr">'.$iniError.'</div>
159                                 </td>
160                         </tr>';
161
162 if($popupBoolean) {
163 /*      echo '  <tr><td>&nbsp;</td><td>&nbsp;</td></tr><tr>
164                                 <td></td>
165                                 <td>
166                                         <form name="form">
167                                         <input name="close" type="button" title="'.$mod_strings['LBL_CLOSE_POPUP'].'"  value="    '.$mod_strings['LBL_CLOSE_POPUP'].'    " onClick="window.close()">
168                                         </form>
169                                 </td>
170                         </tr>';*/
171 }
172
173 echo '  </table>';
174
175
176 ////    END COMMON CODE
177 ///////////////////////////////////////////////////////////////////////////////
178
179 ?>