コード例 #1
0
ファイル: lib.php プロジェクト: jloguercio/chamilo-lms
/**
* get a proper SQLdump command
* @param object $vmoodledata the complete new host information
* @return string the shell command
*/
function vchamilo_get_database_dump_cmd($vchamilodata)
{
    global $CFG;
    $pgm = vchamilo_get_config('mysql_cmd');
    // Checks the needed program.
    ctrace("load_database_from_dump : checking database command");
    if (!$pgm) {
        $pgm = '/usr/bin/mysql';
        ctrace("Using default database command {$pgm} ");
    }
    $phppgm = str_replace("\\", '/', $pgm);
    $phppgm = str_replace("\"", '', $phppgm);
    $pgm = str_replace("/", DIRECTORY_SEPARATOR, $pgm);
    ctrace('load_database_from_dump : checking command is available');
    if (!is_executable($phppgm)) {
        print_error('databasecommanddoesnotmatchanexecutablefile');
        return false;
    }
    // Retrieves the host configuration (more secure).
    $vchamilodata = vchamilo_make_this();
    if (strstr($vchamilodata->db_host, ':') !== false) {
        list($vchamilodata->db_host, $vchamilodata->db_port) = split(':', $vchamilodata->db_host);
    }
    // Password.
    if (!empty($vchamilodata->db_password)) {
        $vchamilodata->db_password = '******' . escapeshellarg($vchamilodata->db_password) . ' ';
    }
    // Making the command line (see 'vconfig.php' file for defining the right paths).
    $sqlcmd = $pgm . ' -h' . $vchamilodata->db_host . (isset($vchamilodata->db_port) ? ' -P' . $vchamilodata->db_port . ' ' : ' ');
    $sqlcmd .= '-u' . $vchamilodata->db_user . ' ' . $vchamilodata->db_password;
    $sqlcmd .= '%DATABASE% < ';
    return $sqlcmd;
}
コード例 #2
0
         $content .= '</div>';
         $tpl = new Template($tool_name, true, true, false, true, false);
         $tpl->assign('actions', '');
         $tpl->assign('message', $plugininstance->get_lang('vchamilosnapshot1'));
         $tpl->assign('content', $content);
         $tpl->display_one_col_template();
         die;
     } else {
         // continue next step
         $vchamilostep = 1;
     }
 }
 if ($vchamilostep >= 1) {
     if ($wwwroot == $_configuration['root_web']) {
         // Make fake Vchamilo record.
         $vchamilo = vchamilo_make_this();
         $vcoursepath = api_get_path(SYS_COURSE_PATH);
         $vhomepath = api_get_path(SYS_HOME_PATH);
         $varchivepath = api_get_path(SYS_ARCHIVE_PATH);
     } else {
         // Get Vchamilo known record.
         $vchamilos = Database::select('*', 'vchamilo', array('where' => array('root_web = ?' => array($wwwroot))));
         $vchamilo = (object) array_pop($vchamilos);
         $vcoursepath = api_get_path(SYS_COURSE_PATH, (array) $vchamilo);
         $vhomepath = api_get_path(SYS_HOME_PATH, (array) $vchamilo);
         $varchivepath = api_get_path(SYS_ARCHIVE_PATH, (array) $vchamilo);
     }
     if ($vchamilostep == 1) {
         // Auto dump the databases in a master template folder.
         // this will create three files : chamilo_master_main.sql, chamilo_master_statistics.sql, chamilo_master_user_personal.sql
         $errors = vchamilo_dump_databases($vchamilo, $absolute_sqldir . $separator . 'chamilo_master');