Exemplo n.º 1
0
function getPath($path = "", $append = "")
{
    global $config;
    #doPrint("getPath('".$path."', '".$append."')");
    $path = urldecode($path);
    $append = urldecode($append);
    $path = strip_tags($path);
    $append = strip_tags($append);
    $path = stripslashes($path);
    $append = stripslashes($append);
    # strip of trailing /
    $config["searchPath"] = preg_replace("/\\/\$/", "", $config["searchPath"]);
    #doPrint("getPath('".$path."', '".$append."')");
    if ($path == "") {
        $path = "/";
    }
    $origRequest = "/" . $path . "/" . $append;
    #doPrint("0: ".$origRequest);
    $origRequest = preg_replace("/\\/+/", "/", $origRequest);
    #doPrint("1: ".$origRequest);
    if (is_file($config["searchPath"] . "/" . $path . "/" . $append)) {
        $aktPath = dirname($config["searchPath"] . "/" . $path . "/" . $append);
        $origRequest = dirname("/" . $path . "/" . $append);
    } else {
        $aktPath = $config["searchPath"] . "/" . $path . "/" . $append;
    }
    $aktPath = preg_replace("/\\/+/", "/", $aktPath);
    #doPrint("2: ".$aktPath);
    # do the realpath thing...
    $origRequest = myRealpath($origRequest);
    $aktPath = myRealpath($aktPath);
    #doPrint("3a: ".$aktPath);
    #doPrint("3b: ".$origRequest);
    if (is_file($aktPath)) {
        $aktPath = dirname($aktPath);
        #doPrint("4: ".$aktPath);
    }
    if (!is_dir($aktPath)) {
        $aktPath = "";
        #doPrint("5: ".$aktPath);
    }
    #doPrint("6: ".$aktPath);
    if (strpos($aktPath, $config["searchPath"]) !== 0) {
        $origRequest = "/";
        $aktPath = $config["searchPath"];
        #doPrint("6.1: wrong path, resetting");
    }
    if (strpos($origRequest, "/") !== 0) {
        $origRequest = "/" . $origRequest;
    }
    $origRequest = preg_replace("/\\/+/", "/", $origRequest);
    #doPrint("7: ".$origRequest);
    return $origRequest;
}
$cext = $config['cron_extender'] == 0 ? 'pl' : 'cgi';
$scriptName = $_SERVER['SCRIPT_NAME'];
$serverName = $_SERVER['SERVER_NAME'];
$url = substr($scriptName, 0, strrpos($scriptName, '/') + 1);
if (substr($url, -1) != '/') {
    $url .= '/';
}
if (substr($url, 0, 1) != '/') {
    $url = '/' . $url;
}
$refdir = substr($config['cron_execution_path'], 0, 1) == '/' ? '' : $url;
$scriptdir = $config['cron_execution_path'] . 'crondump.' . $cext;
$perlModultest = $config['cron_execution_path'] . "perltest.{$cext}";
$perlSimpletest = $config['cron_execution_path'] . "simpletest.{$cext}";
$scriptentry = myRealpath('./') . $config['paths']['config'];
$cronabsolute = myRealpath('./') . $scriptdir;
if (substr($config['cron_execution_path'], 0, 1) == '/') {
    $cronabsolute = $_SERVER['DOCUMENT_ROOT'] . $scriptdir;
}
$confabsolute = $config['config_file'];
$perlHttpCall = getServerProtocol() . $serverName . $refdir;
$perlHttpCall .= $config['cron_execution_path'] . 'crondump.' . $cext;
$perlHttpCall .= '?config=' . $confabsolute;
$perlCrontabCall = 'perl ' . $cronabsolute . ' -config=' . $confabsolute;
$perlCrontabCall .= ' -html_output=0';
$tplDumpPrepare->assign_vars(array('SESSION_ID' => session_id(), 'CONFIG_FILE' => $config['config_file'], 'POSSIBLE_DUMP_ENCODINGS' => Html::getOptionlist($charsetsDescription, 'utf8'), 'DBS_TO_BACKUP' => $dbsToBackup, 'TABLES_TOTAL' => $dump['tables_total'], 'RECORDS_TOTAL' => String::formatNumber(intval($dump['records_total'])), 'DATASIZE_TOTAL' => byteOutput($dump['datasize_total']), 'NR_OF_DBS' => count($dump['databases']), 'DUMP_COMMENT' => Html::replaceQuotes($dump['comment']), 'PERL_TEST' => $perlSimpletest, 'PERL_MODULTEST' => $perlModultest, 'PERL_HTTP_CALL' => $perlHttpCall, 'PERL_CRONTAB_CALL' => $perlCrontabCall, 'PERL_ABSOLUTE_PATH_OF_CONFIGDIR' => $scriptentry, 'TIMESTAMP' => time()));
if (count($dump['databases']) == 1 && $config['db_actual'] == $dbsToBackup) {
    $tplDumpPrepare->assign_block_vars('TABLESELECT', array());
}
if ($config['compression'] == 1) {
    $tplDumpPrepare->assign_block_vars('GZIP_ACTIVATED', array());
Exemplo n.º 3
0
$databases = array();
$tableInfos = array();
$lang = array();
if (!isset($_SESSION['config']) || isset($install)) {
    // set configuration default values if page is loaded the first time or
    // while installation is running
    // will be overwritten by saved values in configuration profile if present
    // this way we make double sure all values are defined
    if (isset($_SESSION['config'])) {
        $config = $_SESSION['config'];
    }
    $config['msd_mode'] = 0;
    // 0=easy, 1=expert
    $config['paths'] = array();
    $config['files'] = array();
    $config['paths']['root'] = myRealpath();
    define('MSD_PATH', $config['paths']['root']);
    $config['paths']['work'] = 'work/';
    $config['paths']['backup'] = $config['paths']['work'] . 'backup/';
    $config['paths']['log'] = $config['paths']['work'] . 'log/';
    $config['paths']['config'] = $config['paths']['work'] . 'config/';
    $config['paths']['perlexec'] = 'msd_cron/';
    $config['files']['log'] = $config['paths']['log'] . 'mysqldump.log';
    $config['files']['perllog'] = $config['paths']['log'] . 'mysqldump_perl.log';
    $config['files']['perllogcomplete'] = $config['paths']['log'] . 'mysqldump_perl.complete.log';
    $config['config_file'] = 'mysqldumper';
    $config['theme'] = 'msd';
    // gui related values
    // show server caption
    $config['interface_server_caption'] = 1;
    // show server caption in main frame