]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - install/dbConfig_a.php
Release 6.5.0
[Github/sugarcrm.git] / install / dbConfig_a.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-2012 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 global $sugar_version, $js_custom_version;
41
42
43 if(empty($_SESSION['setup_db_host_name'])){
44       $_SESSION['setup_db_host_name'] = (isset($sugar_config['db_host_name']))  ? $sugar_config['db_host_name'] :  $_SERVER['SERVER_NAME'];
45 }
46
47 if( !isset( $install_script ) || !$install_script ){
48         die($mod_strings['ERR_NO_DIRECT_SCRIPT']);
49 }
50
51
52 // DB split
53 $createDbCheckbox = '';
54 $createDb = (!empty($_SESSION['setup_db_create_database'])) ? 'checked="checked"' : '';
55 $dropCreate = (!empty($_SESSION['setup_db_drop_tables'])) ? 'checked="checked"' : '';
56 $instanceName = '';
57 if (isset($_SESSION['setup_db_host_instance']) && !empty($_SESSION['setup_db_host_instance'])){
58         $instanceName = $_SESSION['setup_db_host_instance'];
59 }
60
61 $setupDbPortNum ='';
62 if (isset($_SESSION['setup_db_port_num']) && !empty($_SESSION['setup_db_port_num'])){
63         $setupDbPortNum = $_SESSION['setup_db_port_num'];
64 }
65
66 $db = getInstallDbInstance();
67
68 ///////////////////////////////////////////////////////////////////////////////
69 ////    BEGIN PAGE OUTPUT
70
71 $langHeader = get_language_header();
72
73 $out =<<<EOQ
74 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
75 <html {$langHeader}>
76 <head>
77     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
78     <meta http-equiv="Content-Script-Type" content="text/javascript">
79     <meta http-equiv="Content-Style-Type" content="text/css">
80     <title>{$mod_strings['LBL_WIZARD_TITLE']} {$mod_strings['LBL_DBCONF_TITLE']}</title>
81     <link rel="stylesheet" href="install/install.css" type="text/css" />
82     <script type="text/javascript" src="install/installCommon.js"></script>
83     <script type="text/javascript" src="install/dbConfig.js"></script>
84     <link REL="SHORTCUT ICON" HREF="include/images/sugar_icon.ico">
85     <script src="cache/include/javascript/sugar_grp1_yui.js?s={$sugar_version}&c={$js_custom_version}"></script>
86     <script src="cache/include/javascript/sugar_grp1_jquery.js?s={$sugar_version}&c={$js_custom_version}"></script>
87     <script type="text/javascript">
88     <!--
89     if ( YAHOO.env.ua )
90         UA = YAHOO.env.ua;
91     -->
92     </script>
93     <link rel='stylesheet' type='text/css' href='include/javascript/yui/build/container/assets/container.css' />
94
95 </head>
96 EOQ;
97 $out .= '<body onload="document.getElementById(\'button_next2\').focus();">';
98
99 $out2 =<<<EOQ2
100 <form action="install.php" method="post" name="setConfig" id="form">
101 <input type='hidden' name='setup_db_drop_tables' id='setup_db_drop_tables' value=''>
102 <input type="hidden" id="hidden_goto" name="goto" value="{$mod_strings['LBL_BACK']}" />
103 <table cellspacing="0" cellpadding="0" border="0" align="center" class="shell">
104
105       <tr><td colspan="2" id="help"><a href="{$help_url}" target='_blank'>{$mod_strings['LBL_HELP']} </a></td></tr>
106     <tr>
107       <th width="500">
108                 <p>
109                 <img src="{$sugar_md}" alt="SugarCRM" border="0">
110                 </p>
111                 {$mod_strings['LBL_DBCONF_TITLE']}
112         </th>
113         <th width="200" height="30" style="text-align: right;"><a href="http://www.sugarcrm.com" target="_blank">
114                 <IMG src="include/images/sugarcrm_login.png" alt="SugarCRM" border="0"></a>
115         </th>
116 </tr>
117 <tr>
118         <td colspan="2">
119 <div id="errorMsgs" style="display:none"></div>
120 <div class="required">{$mod_strings['LBL_REQUIRED']}</div>
121 <table width="100%" cellpadding="0" cellpadding="0" border="0" class="StyleDottedHr">
122 <tr><th colspan="3" align="left" >{$mod_strings['LBL_DBCONF_TITLE_NAME']} </td></tr>
123
124 EOQ2;
125
126 $config_params = $db->installConfig();
127 $form = '';
128 foreach($config_params as $group => $gdata) {
129     $form .= "<tr><td colspan=\"3\" align=\"left\">{$mod_strings[$group]}</td></tr>\n";
130     foreach($gdata as $name => $value) {
131         if(!empty($value)) {
132             $form .= "<tr>";
133             if(!empty($value['required'])) {
134                $form .= "<td><span class=\"required\">*</span></td>\n";
135             } else {
136                 $form .= "<td>&nbsp;</td>\n";
137             }
138             if(!empty($_SESSION[$name])) {
139                 $sessval = $_SESSION[$name];
140             } else {
141                 $sessval = '';
142             }
143             if(!empty($value["type"])) {
144                 $type = $value["type"];
145             } else {
146                 $type = '';
147             }
148
149             $form .= <<<FORM
150             <td nowrap><b>{$mod_strings[$value["label"]]}</b></td>
151             <td align="left">
152 FORM;
153             //if the type is password, set a hidden field to capture the value.  This is so that we can properly encode special characters, which is a limitation with password fields
154             if($type=='password'){
155                 $form .= "<input type='$type' name='{$name}_entry' id='{$name}_entry' value='".urldecode($sessval)."'><input type='hidden' name='$name' id='$name' value='".urldecode($sessval)."'>";
156             }else{
157                 $form .= "<input type='$type' name='$name' id='$name' value='$sessval'>";
158             }
159
160
161
162             $form .= <<<FORM
163             </td></tr>
164 FORM;
165
166         } else {
167             $form .= "<input name=\"$name\" id=\"$name\" value=\"\" type=\"hidden\">\n";
168         }
169     }
170 }
171
172 $out2 .= $form;
173
174 //if we are installing in custom mode, include the following html
175 if($db->supports("create_user")){
176 // create / set db user dropdown
177 $auto_select = '';$provide_select ='';$create_select = '';$same_select = '';
178 if(isset($_SESSION['dbUSRData'])){
179 //    if($_SESSION['dbUSRData']=='auto')    {$auto_select ='selected';}
180     if($_SESSION['dbUSRData']=='provide') {$provide_select ='selected';}
181 if(isset($_SESSION['install_type'])  && !empty($_SESSION['install_type'])  && strtolower($_SESSION['install_type'])=='custom'){
182     if($_SESSION['dbUSRData']=='create')  {$create_select ='selected';}
183 }
184     if($_SESSION['dbUSRData']=='same')  {$same_select ='selected';}
185 }else{
186     $same_select ='selected';
187 }
188 $dbUSRDD   = "<select name='dbUSRData' id='dbUSRData' onchange='toggleDBUser();'>";
189 $dbUSRDD  .= "<option value='provide' $provide_select>".$mod_strings['LBL_DBCONFIG_PROVIDE_DD']."</option>";
190 $dbUSRDD  .= "<option value='create' $create_select>".$mod_strings['LBL_DBCONFIG_CREATE_DD']."</option>";
191 $dbUSRDD  .= "<option value='same' $same_select>".$mod_strings['LBL_DBCONFIG_SAME_DD']."</option>";
192 $dbUSRDD  .= "</select><br>&nbsp;";
193
194
195
196 $setup_db_sugarsales_password = urldecode($_SESSION['setup_db_sugarsales_password']);
197 $setup_db_sugarsales_user = urldecode($_SESSION['setup_db_sugarsales_user']);
198 $setup_db_sugarsales_password_retype = urldecode($_SESSION['setup_db_sugarsales_password_retype']);
199
200 $out2 .=<<<EOQ2
201
202 <table width="100%" cellpadding="0" cellpadding="0" border="0" class="StyleDottedHr">
203 <tr><td colspan="3" align="left"><br>{$mod_strings['LBL_DBCONFIG_SECURITY']}</td></tr>
204 <tr><td width='1%'>&nbsp;</td><td width='60%'><div id='sugarDBUser'><b>{$mod_strings['LBL_DBCONF_SUGAR_DB_USER']}</b></div>&nbsp;</td><td width='35%'>$dbUSRDD</td></tr>
205 </table>
206
207 <span id='connection_user_div' style="display:none">
208 <table width="100%" cellpadding="0" cellpadding="0" border="0" class="StyleDottedHr">
209     <tr>
210         <td width='1%'><span class="required">*</span></td>
211         <td nowrap width='60%'><b>{$mod_strings['LBL_DBCONF_SUGAR_DB_USER']}</b></td>
212         <td  width='35%'nowrap align="left">
213          <input type="text" name="setup_db_sugarsales_user" maxlength="16" value="{$_SESSION['setup_db_sugarsales_user']}" />
214         </td>
215 </tr>
216 <tr>
217     <td>&nbsp;</td>
218     <td nowrap><b>{$mod_strings['LBL_DBCONF_DB_PASSWORD']}</b></td>
219     <td nowrap align="left"><input type="password" name="setup_db_sugarsales_password_entry" value="{$setup_db_sugarsales_password}" /><input type="hidden" name="setup_db_sugarsales_password" value="{$setup_db_sugarsales_password}" /></td>
220     <input type="hidden" name="setup_db_sugarsales_password" value="{$_SESSION['setup_db_sugarsales_password']}" /></td>
221 </tr>
222 <tr>
223     <td>&nbsp;</td>
224     <td nowrap><b>{$mod_strings['LBL_DBCONF_DB_PASSWORD2']}</b></td>
225     <td nowrap align="left"><input type="password" name="setup_db_sugarsales_password_retype_entry" value="{$setup_db_sugarsales_password_retype}"  /><input type="hidden" name="setup_db_sugarsales_password_retype" value="{$setup_db_sugarsales_password_retype}" /></td>
226 </tr></table>
227 </span>
228
229 EOQ2;
230 }
231
232 $demoDD = "<select name='demoData' id='demoData'><option value='no' >".$mod_strings['LBL_NO']."</option><option value='yes'>".$mod_strings['LBL_YES']."</option>";
233 $demoDD .= "</select><br>&nbsp;";
234
235
236 $out3 =<<<EOQ3
237 <table width="100%" cellpadding="0" cellpadding="0" border="0" class="StyleDottedHr">
238 <tr><th colspan="3" align="left">{$mod_strings['LBL_DBCONF_DEMO_DATA_TITLE']}</th></tr>
239 <tr>
240     <td width='1%'>&nbsp;</td>
241     <td  width='60%'nowrap><b>{$mod_strings['LBL_DBCONF_DEMO_DATA']}</b></td>
242     <td  width='35%'nowrap align="left">
243         {$demoDD}
244     </td>
245 </tr>
246 </table>
247 EOQ3;
248
249
250
251 $out4 =<<<EOQ4
252 </td>
253 </tr>
254 <tr>
255 <td align="right" colspan="2">
256 <hr>
257      <input type="hidden" name="current_step" value="{$next_step}">
258      <table cellspacing="0" cellpadding="0" border="0" class="stdTable">
259         <tr>
260             <td>
261                 <input class="button" type="button" name="goto" value="{$mod_strings['LBL_BACK']}" id="button_back_dbConfig" onclick="document.getElementById('form').submit();" />
262             </td>
263             <td>
264                 <input class="button" type="button" name="goto" id="button_next2" value="{$mod_strings['LBL_NEXT']}" onClick="callDBCheck();"/>
265             </td>
266         </tr>
267      </table>
268 </td>
269 </tr>
270 </table>
271 </form>
272 <br>
273
274 <script>
275
276 $('#fts_type').change(function(){
277     if($(this).val() == '')
278         hideFTSSettings();
279     else
280         showFTSSettings();
281 });
282
283 function showFTSSettings()
284 {
285     $('#fts_port_row').show();
286     $('#fts_host_row').show();
287 }
288
289 function hideFTSSettings()
290 {
291     $('#fts_port_row').hide();
292     $('#fts_host_row').hide();
293 }
294
295 function toggleDBUser(){
296      if(typeof(document.getElementById('dbUSRData')) !='undefined'
297      && document.getElementById('dbUSRData') != null){
298
299         ouv = document.getElementById('dbUSRData').value;
300         if(ouv == 'provide' || ouv == 'create'){
301             document.getElementById('connection_user_div').style.display = '';
302             document.getElementById('sugarDBUser').style.display = 'none';
303         }else{
304             document.getElementById('connection_user_div').style.display = 'none';
305             document.getElementById('sugarDBUser').style.display = '';
306         }
307     }
308 }
309     toggleDBUser();
310
311 var msgPanel;
312 function callDBCheck(){
313
314             //begin main function that will be called
315             ajaxCall = function(msg_panel){
316                 //create success function for callback
317
318                 getPanel = function() {
319                 var args = {    width:"300px",
320                                 modal:true,
321                                 fixedcenter: true,
322                                 constraintoviewport: false,
323                                 underlay:"shadow",
324                                 close:false,
325                                 draggable:true,
326
327                                 effect:{effect:YAHOO.widget.ContainerEffect.FADE, duration:.5}
328                                } ;
329                         msg_panel = new YAHOO.widget.Panel('p_msg', args);
330
331                         msg_panel.setHeader("{$mod_strings['LBL_LICENSE_CHKDB_HEADER']}");
332                         msg_panel.setBody(document.getElementById("checkingDiv").innerHTML);
333                         msg_panel.render(document.body);
334                         msgPanel = msg_panel;
335                 }
336
337
338                 passed = function(url){
339                     document.setConfig.goto.value="{$mod_strings['LBL_NEXT']}";
340                     document.getElementById('hidden_goto').value="{$mod_strings['LBL_NEXT']}";
341                     document.setConfig.current_step.value="{$next_step}";
342                     document.setConfig.submit();
343                 }
344                 success = function(o) {
345
346                     //condition for just the preexisting database
347                     if (o.responseText.indexOf('preexeest')>=0){
348
349                         //  throw confirmation message
350                         msg_panel.setBody(document.getElementById("sysCheckMsg").innerHTML);
351                         msg_panel.render(document.body);
352                         msgPanel = msg_panel;
353                         document.getElementById('accept_btn').focus();
354                     //condition for no errors
355                     }else if (o.responseText.indexOf('dbCheckPassed')>=0){
356                         //make navigation
357                         passed("install.php?goto={$mod_strings['LBL_NEXT']}");
358
359                     //condition for other errors
360                     }else{
361                         //turn off loading message
362                         msgPanel.hide();
363                         document.getElementById("errorMsgs").innerHTML = o.responseText;
364                         document.getElementById("errorMsgs").style.display = '';
365                         return false;
366                     }
367
368
369                 }//end success
370
371
372                 //copy the db values over to the hidden field counterparts
373                 document.setConfig.setup_db_admin_password.value = document.setConfig.setup_db_admin_password_entry.value;
374
375
376
377                 //set loading message and create url
378                 postData = "checkDBSettings=true&to_pdf=1&sugar_body_only=1";
379                 postData += "&setup_db_database_name="+document.setConfig.setup_db_database_name.value;
380                 if(typeof(document.setConfig.setup_db_host_instance) != 'undefined'){
381                     postData += "&setup_db_host_instance="+document.setConfig.setup_db_host_instance.value;
382                 }
383                 if(typeof(document.setConfig.setup_db_port_num) != 'undefined'){
384                     postData += "&setup_db_port_num="+document.setConfig.setup_db_port_num.value;
385                 }
386                 postData += "&setup_db_host_name="+document.setConfig.setup_db_host_name.value;
387                 postData += "&setup_db_admin_user_name="+document.setConfig.setup_db_admin_user_name.value;
388                 postData += "&setup_db_admin_password="+encodeURIComponent(document.setConfig.setup_db_admin_password.value);
389                 if(typeof(document.setConfig.setup_db_sugarsales_user) != 'undefined'){
390                     postData += "&setup_db_sugarsales_user="+document.setConfig.setup_db_sugarsales_user.value;
391                 }
392                 if(typeof(document.setConfig.setup_db_sugarsales_password) != 'undefined'){
393                 document.setConfig.setup_db_sugarsales_password.value = document.setConfig.setup_db_sugarsales_password_entry.value;
394                     postData += "&setup_db_sugarsales_password="+encodeURIComponent(document.setConfig.setup_db_sugarsales_password.value);
395                 }
396                 if(typeof(document.setConfig.setup_db_sugarsales_password_retype) != 'undefined'){
397                     document.setConfig.setup_db_sugarsales_password_retype.value = document.setConfig.setup_db_sugarsales_password_retype_entry.value;
398                     postData += "&setup_db_sugarsales_password_retype="+encodeURIComponent(document.setConfig.setup_db_sugarsales_password_retype.value);
399                 }
400                 if(typeof(document.setConfig.dbUSRData) != 'undefined'){
401                     postData += "&dbUSRData="+document.getElementById('dbUSRData').value;
402                 }
403
404 EOQ4;
405
406
407 $out_dd = 'postData += "&demoData="+document.setConfig.demoData.value;';
408 $out5 =<<<EOQ5
409                 postData += "&to_pdf=1&sugar_body_only=1";
410
411                 //if this is a call already in progress, then just return
412                     if(typeof ajxProgress != 'undefined'){
413                         return;
414                     }
415
416                 getPanel();
417                 msgPanel.show;
418                 var ajxProgress = YAHOO.util.Connect.asyncRequest('POST','install.php', {success: success, failure: success}, postData);
419
420
421             };//end ajaxCall method
422               ajaxCall();
423             return;
424 }
425
426 function confirm_drop_tables(yes_no){
427
428         if(yes_no == true){
429             document.getElementById('setup_db_drop_tables').value = true;
430            //make navigation
431                     document.setConfig.goto.value="{$mod_strings['LBL_NEXT']}";
432                     document.getElementById('hidden_goto').value="{$mod_strings['LBL_NEXT']}";
433                     document.setConfig.current_step.value="{$next_step}";
434                     document.setConfig.submit();
435         }else{
436             //set drop tables to false
437             document.getElementById('setup_db_drop_tables').value = false;
438             msgPanel.hide();
439         }
440 }
441
442 </script>
443
444
445
446            <div id="checkingDiv" style="display:none">
447            <table cellspacing="0" cellpadding="0" border="0">
448                <tr><td>
449                     <p><img alt="{$mod_strings['LBL_LICENSE_CHKDB_HEADER']}" src='install/processing.gif'> <br>{$mod_strings['LBL_LICENSE_CHKDB_HEADER']}</p>
450                 </td></tr>
451             </table>
452             </div>
453
454           <div id='sysCheckMsg' style="display:none">
455            <table cellspacing="0" cellpadding="0" border="0" >
456                <tr><td>
457                     <p>{$mod_strings['LBL_DROP_DB_CONFIRM']}</p>
458                </td></tr>
459                <tr><td align='center'>
460                     <input id='accept_btn' type='button' class='button' onclick='confirm_drop_tables(true)' value="{$mod_strings['LBL_ACCEPT']}">
461                     <input type='button' class='button' onclick='confirm_drop_tables(false)' id="button_cancel_dbConfig" value="{$mod_strings['LBL_CANCEL']}">
462                 </td></tr>
463             </table>
464
465           <div>
466
467 </body>
468 </html>
469
470
471
472
473 EOQ5;
474
475
476
477
478 ////    END PAGE OUTPUT
479 ///////////////////////////////////////////////////////////////////////////////
480
481
482
483 echo $out;
484 echo $out2;
485     echo $out3;
486 echo $out4;
487     echo $out_dd;
488 echo $out5;
489
490 ?>