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