} } } else { $url = 'local_arc_name=' . htmlspecialcharsbx($name); } if ($url) { echo '<script>document.location = "/restore.php?Step=1&' . $url . '";</script>'; } die; } elseif ($_REQUEST['action'] == 'restore.php') { if (CModule::IncludeModule("compression")) { Ccompress::DisableCompression(); } if ($contents = file_get_contents($f = DOCUMENT_ROOT . BX_ROOT . '/modules/main/admin/restore.php')) { header("Content-Type: application/octet-stream"); header("Content-Length: " . CTar::strlen($contents)); header("Content-Disposition: attachment; filename=\"restore.php\""); header("Expires: 0"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); echo $contents; } else { CAdminMessage::ShowMessage(array("MESSAGE" => GetMessage("MAIN_DUMP_ERROR"), "DETAILS" => GetMessage("MAIN_DUMP_ERR_COPY_FILE") . htmlspecialcharsbx($f), "TYPE" => "ERROR", "HTML" => true)); } die; } } require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/prolog.php"; ######### Admin list ####### #$arFilterFields = array(); #$lAdmin->InitFilter($arFilterFields);
function ProcessFile($f) { global $tar; while (haveTime()) { $f = str_replace('\\', '/', $f); if (strpos($f, 'bitrix/php_interface/dbconn.php')) { $path = substr($f, strlen($tar->path) + 1); if (!($ar = $tar->getFileInfo($f))) { return false; } if (!($arFile = file($f))) { return false; } $strFile = ''; foreach ($arFile as $line) { if (preg_match("#^[ \t]*" . '\\$' . "(DB(Login|Password|Name))#", $line, $regs)) { $strFile .= '$' . $regs[1] . ' = "******";' . "\n"; } else { $strFile .= str_replace("\r\n", "\n", $line); } } $ar['size'] = CTar::strlen($strFile); if (!$tar->writeHeader($ar)) { return false; } $i = 0; while ($i < $ar['size']) { if (!$tar->writeBlock(pack("a512", CTar::substr($strFile, $i, 512)))) { return false; } $i += 512; } return true; } if ($tar->addFile($f) === false) { return false; } // error if ($tar->ReadBlockCurrent == 0) { return true; } // finished } return 'BREAK'; }
function ProcessFile($f) { global $tar; while (haveTime()) { $f = str_replace('\\', '/', $f); if (preg_match('#/bitrix/(php_interface/dbconn.php|.settings.php)$#', $f, $regs)) { if (!($arInfo = $tar->getFileInfo($f))) { return false; } if ($regs[1] == '.settings.php') { if (!is_array($ar = (include $f))) { $this->err[] = 'Can\'t parse file: ' . $f; return false; } if (is_array($ar['connections']['value'])) { foreach ($ar['connections']['value'] as $k => $arTmp) { $ar['connections']['value'][$k]['login'] = '******'; $ar['connections']['value'][$k]['password'] = '******'; $ar['connections']['value'][$k]['database'] = '******'; } } $strFile = "<" . "?php\nreturn " . var_export($ar, true) . ";\n"; } else { if (false === ($arFile = file($f))) { $this->err[] = 'Can\'t read file: ' . $f; return false; } $strFile = ''; foreach ($arFile as $line) { if (preg_match("#^[ \t]*" . '\\$' . "(DB(Login|Password|Name))#", $line, $regs)) { $strFile .= '$' . $regs[1] . ' = "******";' . "\n"; } else { $strFile .= str_replace("\r\n", "\n", $line); } } } $arInfo['size'] = CTar::strlen($strFile); if (!$tar->writeHeader($arInfo)) { return false; } $i = 0; while ($i < $arInfo['size']) { if (!$tar->writeBlock(pack("a512", CTar::substr($strFile, $i, 512)))) { return false; } $i += 512; } return true; } if ($tar->addFile($f) === false) { return false; } // error if ($tar->ReadBlockCurrent == 0) { return true; } // finished } return 'BREAK'; }
function Scan($dir) { if (!$this->cut) $this->cut = CTar::strlen($dir) + 1; // 1 for "/" return parent::Scan($dir); }