dolibarr  7.0.0-beta
dolibarr_import.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2006-2012 Regis Houssin <regis.houssin@capnetworks.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
25 require '../../main.inc.php';
26 
27 $langs->load("admin");
28 $langs->load("other");
29 
30 if (! $user->admin)
32 
33 $radio_dump=GETPOST('radio_dump');
34 $showpass=GETPOST('showpass');
35 
36 
37 /*
38  * View
39  */
40 
41 $label=$db::LABEL;
42 $type=$db->type;
43 
44 
45 $help_url='EN:Restores|FR:Restaurations|ES:Restauraciones';
46 llxHeader('','',$help_url);
47 
48 ?>
49 <script type="text/javascript">
50 jQuery(document).ready(function() {
51  jQuery("#mysql_options").<?php echo $radio_dump=='mysql_options'?'show()':'hide()'; ?>;
52  jQuery("#postgresql_options").<?php echo $radio_dump=='postgresql_options'?'show()':'hide()'; ?>;
53 
54  jQuery("#radio_dump_mysql").click(function() {
55  jQuery("#mysql_options").show();
56  });
57  jQuery("#radio_dump_postgresql").click(function() {
58  jQuery("#postgresql_options").show();
59  });
60  <?php
61  if ($label == 'MySQL') print 'jQuery("#radio_dump_mysql").click();';
62  if ($label == 'PostgreSQL') print 'jQuery("#radio_dump_postgresql").click();';
63  ?>
64 });
65 </script>
66 <?php
67 
68 print load_fiche_titre($langs->trans("Restore"),'','title_setup');
69 
70 print '<div class="center">';
71 print $langs->trans("RestoreDesc",DOL_DATA_ROOT);
72 print '</div>';
73 print '<br>';
74 
75 ?>
76 <fieldset>
77 <legend style="font-size: 3em">1</legend>
78 <?php
79 print $langs->trans("RestoreDesc2",DOL_DATA_ROOT).'<br><br>';
80 ?>
81 </fieldset>
82 
83 <br>
84 
85 <fieldset>
86 <legend style="font-size: 3em">2</legend>
87 <?php
88 print $langs->trans("RestoreDesc3",$dolibarr_main_db_name).'<br><br>';
89 ?>
90 
91 <?php print $langs->trans("DatabaseName").' : <b>'.$dolibarr_main_db_name.'</b>'; ?><br><br>
92 
93 <table class="centpercent"><tr><td class="tdtop">
94 
95 <?php if ($conf->use_javascript_ajax) { ?>
96 <div id="div_container_exportoptions">
97 <fieldset id="exportoptions">
98  <legend><?php echo $langs->trans("ImportMethod"); ?></legend>
99  <?php
100  if (in_array($type, array('mysql', 'mysqli')))
101  {
102  ?>
103  <div class="formelementrow">
104  <input type="radio" name="what" value="mysql" id="radio_dump_mysql"<?php echo ($radio_dump=='mysql_options'?' checked':''); ?> />
105  <label for="radio_dump_mysql">MySQL (mysql)</label>
106  </div>
107  <?php
108  }
109  else if (in_array($type, array('pgsql')))
110  {
111  ?>
112  <div class="formelementrow">
113  <input type="radio" name="what" value="mysql" id="radio_dump_postgresql"<?php echo ($radio_dump=='postgresql_options'?' checked':''); ?> />
114  <label for="radio_dump_postgresql">PostgreSQL Restore (pg_restore or psql)</label>
115  </div>
116  <?php
117  }
118  else
119  {
120  print 'No method available with database '.$label;
121  }
122  ?>
123 </fieldset>
124 </div>
125 <?php } ?>
126 
127 </td><td class="tdtop">
128 
129 
130 <div id="div_container_sub_exportoptions" >
131 <?php
132 if (in_array($type, array('mysql', 'mysqli')))
133 {
134 ?>
135  <fieldset id="mysql_options">
136  <legend><?php echo $langs->trans('RestoreMySQL') ?></legend>
137  <div class="formelementrow centpercent">
138  <?php
139  // Parameteres execution
140  $command=$db->getPathOfRestore();
141  if (preg_match("/\s/",$command)) $command=$command=escapeshellarg($command); // Use quotes on command
142 
143  $param=$dolibarr_main_db_name;
144  $param.=" -h ".$dolibarr_main_db_host;
145  if (! empty($dolibarr_main_db_port)) $param.=" -P ".$dolibarr_main_db_port;
146  $param.=" -u ".$dolibarr_main_db_user;
147  $paramcrypted=$param;
148  $paramclear=$param;
149  if (! empty($dolibarr_main_db_pass))
150  {
151  $paramcrypted.=" -p".preg_replace('/./i','*',$dolibarr_main_db_pass);
152  $paramclear.=" -p".$dolibarr_main_db_pass;
153  }
154 
155  echo $langs->trans("ImportMySqlDesc");
156  print '<br>';
157  print '<textarea rows="1" id="restorecommand" class="centpercent">'.$langs->trans("ImportMySqlCommand",$command,($showpass?$paramclear:$paramcrypted)).'</textarea><br>';
158  print ajax_autoselect('restorecommand');
159 
160  if (empty($_GET["showpass"]) && $dolibarr_main_db_pass) print '<br><a href="'.$_SERVER["PHP_SELF"].'?showpass=1&amp;radio_dump=mysql_options">'.$langs->trans("UnHidePassword").'</a>';
161  //else print '<br><a href="'.$_SERVER["PHP_SELF"].'?showpass=0&amp;radio_dump=mysql_options">'.$langs->trans("HidePassword").'</a>';
162  ?>
163  </div>
164  </fieldset>
165 <?php
166 }
167 else if (in_array($type, array('pgsql')))
168 {
169 ?>
170  <fieldset id="postgresql_options">
171  <legend>Restore PostgreSQL</legend>
172  <div class="formelementrow">
173  <?php
174  // Parameteres execution
175  $command=$db->getPathOfRestore();
176  if (preg_match("/\s/",$command)) $command=$command=escapeshellarg($command); // Use quotes on command
177 
178  $param=" -d ".$dolibarr_main_db_name;
179  $param.=" -h ".$dolibarr_main_db_host;
180  if (! empty($dolibarr_main_db_port)) $param.=" -p ".$dolibarr_main_db_port;
181  $param.=" -U ".$dolibarr_main_db_user;
182  $paramcrypted=$param;
183  $paramclear=$param;
184  /*if (! empty($dolibarr_main_db_pass))
185  {
186  $paramcrypted.=" -p".preg_replace('/./i','*',$dolibarr_main_db_pass);
187  $paramclear.=" -p".$dolibarr_main_db_pass;
188  }*/
189  $paramcrypted.=" -W";
190  $paramclear.=" -W";
191  // With psql:
192  $paramcrypted.=" -f";
193  $paramclear.=" -f";
194 
195  echo $langs->trans("ImportPostgreSqlDesc");
196  print '<br>';
197  print '<textarea rows="1" id="restorecommand" class="centpercent">'.$langs->trans("ImportPostgreSqlCommand",$command,($showpass?$paramclear:$paramcrypted)).'</textarea><br>';
198  print ajax_autoselect('restorecommand');
199  //if (empty($_GET["showpass"]) && $dolibarr_main_db_pass) print '<br><a href="'.$_SERVER["PHP_SELF"].'?showpass=1&amp;radio_dump=postgresql_options">'.$langs->trans("UnHidePassword").'</a>';
200  //else print '<br><a href="'.$_SERVER["PHP_SELF"].'?showpass=0&amp;radio_dump=mysql_options">'.$langs->trans("HidePassword").'</a>';
201  ?>
202  </div>
203  </fieldset>
204 <?php
205 }
206 ?>
207 
208 </div>
209 
210 
211 </td></tr></table>
212 </fieldset>
213 
214 <?php
215 llxFooter();
216 
217 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
ajax_autoselect($htmlname, $addlink='')
Make content of an input box selected when we click into input field.
Definition: ajax.lib.php:367
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
llxHeader()
Empty header.
Definition: wrapper.php:46
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:104
print
Draft customers invoices.
Definition: index.php:91
type
Definition: viewcat.php:283