/** * Restores the Campsite database from the given dump file. * @param $p_sqlFile - dump file * @return bool - true on success */ function camp_restore_database($p_sqlFile, $p_silent = false) { global $Campsite; $cmd = "%s -u " . $Campsite['DATABASE_USER'] . " --host=" . $Campsite['DATABASE_SERVER_ADDRESS'] . " --port=" . $Campsite['DATABASE_SERVER_PORT'] . ' --default-character-set=utf8'; if ($Campsite['DATABASE_PASSWORD'] != "") { $cmd .= " --password=\"" . $Campsite['DATABASE_PASSWORD'] . "\""; } $cmd .= ' ' . $Campsite['DATABASE_NAME'] . " < {$p_sqlFile}"; $cmdpath = 'mysql'; exec(sprintf($cmd, $cmdpath), $o, $r); if ($r !== 0) { $testcmd = exec("which {$cmdpath}"); if (trim($testcmd) != '') { $cmdpath = exec(sprintf($cmd, $testcmd)); } } camp_exec_command(sprintf($cmd, 'mysql'), "Unable to import database. (Command: {$cmd})", true, $p_silent); return true; }
/** * Restores the Campsite database from the given dump file. * @param $p_sqlFile - dump file * @return bool - true on success */ function camp_restore_database($p_sqlFile, $p_silent = false) { global $Campsite; $cmd = "mysql -u " . $Campsite['DATABASE_USER'] . " --host=" . $Campsite['DATABASE_SERVER_ADDRESS'] . " --port=" . $Campsite['DATABASE_SERVER_PORT'] . ' --default-character-set=utf8'; if ($Campsite['DATABASE_PASSWORD'] != "") { $cmd .= " --password=\"" . $Campsite['DATABASE_PASSWORD'] . "\""; } $cmd .= ' ' . $Campsite['DATABASE_NAME'] . " < $p_sqlFile"; camp_exec_command($cmd, "Unable to import database. (Command: $cmd)", true, $p_silent); return true; }