dolibarr /htdocs/admin/tools/dolibarr_import.php

Language PHP Lines 187
MD5 Hash f16bcd9994fc60599fc66c4900777e9f Estimated Cost $1,581 (why?)
Repository https://github.com/asterix14/dolibarr.git View Raw File
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<?php
/* Copyright (C) 2006-2010 Laurent Destailleur  <eldy@users.sourceforge.net>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

/**
 *		\file 		htdocs/admin/tools/dolibarr_import.php
 *		\ingroup	core
 * 		\brief      Page to import database
 */

require("../../main.inc.php");

$langs->load("admin");
$langs->load("other");

if (! $user->admin)
  accessforbidden();


/*
 * View
 */

llxHeader('','','EN:Restores|FR:Restaurations|ES:Restauraciones');

?>
<script type="text/javascript">
jQuery(document).ready(function() {
	jQuery("#mysql_options").<?php echo GETPOST('radio_dump')=='mysql_options'?'show()':'hide()'; ?>;
	jQuery("#postgresql_options").<?php echo GETPOST('radio_dump')=='postgresql_options'?'show()':'hide()'; ?>;

	jQuery("#radio_dump_mysql").click(function() {
		jQuery("#mysql_options").show();
	});
	jQuery("#radio_dump_postgresql").click(function() {
		jQuery("#postgresql_options").show();
	});
});
</script>
<?php

print_fiche_titre($langs->trans("Restore"),'','setup');

print $langs->trans("RestoreDesc",DOL_DATA_ROOT).'<br><br>';
print $langs->trans("RestoreDesc2",DOL_DATA_ROOT).'<br><br>';
print $langs->trans("RestoreDesc3",DOL_DATA_ROOT).'<br><br>';

?>

<fieldset id="fieldsetexport">
<?php print '<legend>'.$langs->trans("DatabaseName").' : <b>'.$dolibarr_main_db_name.'</b></legend>'; ?>
<table><tr><td valign="top">

<?php if ($conf->use_javascript_ajax) { ?>
<div id="div_container_exportoptions">
<fieldset id="exportoptions">
	<legend><?php echo $langs->trans("ImportMethod"); ?></legend>
    <?php
    if ($db->label == 'MySQL')
    {
    ?>
    <div class="formelementrow">
        <input type="radio" name="what" value="mysql" id="radio_dump_mysql"	<?php echo ($_GET["radio_dump"]=='mysql_options'?' checked':''); ?> />
        <label for="radio_dump_mysql">MySQL (mysql)</label>
    </div>
    <?php
    }
    else if ($db->label == 'PostgreSQL')
    {
    ?>
    <div class="formelementrow">
        <input type="radio" name="what" value="mysql" id="radio_dump_postgresql" <?php echo ($_GET["radio_dump"]=='postgresql_options'?' checked':''); ?> />
        <label for="radio_dump_postgresql">PostgreSQL Restore (pg_restore)</label>
    </div>
    <?php
    }
    else
    {
        print 'No method available with database '.$db->label;
    }
    ?>
</fieldset>
</div>
<?php } ?>

</td><td valign="top">


<div id="div_container_sub_exportoptions">
<?php
if ($db->label == 'MySQL')
{
?>
	<fieldset id="mysql_options">
    <legend>Import MySql</legend>
	<div class="formelementrow">
	<?php
	// Parameteres execution
	$command=$db->getPathOfRestore();
	if (preg_match("/\s/",$command)) $command=$command=escapeshellarg($command);	// Use quotes on command

	$param=$dolibarr_main_db_name;
	$param.=" -h ".$dolibarr_main_db_host;
	if (! empty($dolibarr_main_db_port)) $param.=" -P ".$dolibarr_main_db_port;
	$param.=" -u ".$dolibarr_main_db_user;
	$paramcrypted=$param;
	$paramclear=$param;
	if (! empty($dolibarr_main_db_pass))
	{
		$paramcrypted.=" -p".preg_replace('/./i','*',$dolibarr_main_db_pass);
		$paramclear.=" -p".$dolibarr_main_db_pass;
	}

	echo $langs->trans("ImportMySqlDesc");
	print '<br>';
	print '<textarea rows="1" cols="120">'.$langs->trans("ImportMySqlCommand",$command,$_GET["showpass"]?$paramclear:$paramcrypted).'</textarea><br>';

	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>';
	//else print '<br><a href="'.$_SERVER["PHP_SELF"].'?showpass=0&amp;radio_dump=mysql_options">'.$langs->trans("HidePassword").'</a>';
	?>
	</div>
    </fieldset>
<?php
}
else if ($db->label == 'PostgreSQL')
{
?>
    <fieldset id="postgresql_options">
    <legend>Restore PostgreSQL</legend>
    <div class="formelementrow">
    <?php
    // Parameteres execution
    $command=$db->getPathOfRestore();
    if (preg_match("/\s/",$command)) $command=$command=escapeshellarg($command);    // Use quotes on command

    $param=" -d ".$dolibarr_main_db_name;
    $param.=" -h ".$dolibarr_main_db_host;
    if (! empty($dolibarr_main_db_port)) $param.=" -p ".$dolibarr_main_db_port;
    $param.=" -U ".$dolibarr_main_db_user;
    $paramcrypted=$param;
    $paramclear=$param;
    /*if (! empty($dolibarr_main_db_pass))
    {
        $paramcrypted.=" -p".preg_replace('/./i','*',$dolibarr_main_db_pass);
        $paramclear.=" -p".$dolibarr_main_db_pass;
    }*/
    $paramcrypted.=" -W";
    $paramclear.=" -W";

    echo $langs->trans("ImportPostgreSqlDesc");
    print '<br>';
    print '<textarea rows="1" cols="120">'.$langs->trans("ImportPostgreSqlCommand",$command,$_GET["showpass"]?$paramclear:$paramcrypted).'</textarea><br>';

    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>';
    //else print '<br><a href="'.$_SERVER["PHP_SELF"].'?showpass=0&amp;radio_dump=mysql_options">'.$langs->trans("HidePassword").'</a>';
    ?>
    </div>
    </fieldset>
<?php
}
?>

</div>


</td></tr></table>
</fieldset>

<?php

$db->close();

llxFooter();
?>
Back to Top