function recursively_get_file($dir, $file) { if (lxfile_exists("{$dir}/{$file}")) { return "{$dir}/{$file}"; } $list = lscandir_without_dot($dir); if (!$list) { return null; } foreach ($list as $l) { if (lxfile_exists("{$dir}/{$l}/{$file}")) { return "{$dir}/{$l}/{$file}"; } } return recursively_get_file("{$dir}/{$l}", $file); }
static function getMetaData($file) { global $gbl, $sgbl, $login, $ghtml; $progname = $sgbl->__var_program_name; if (!lxfile_exists($file)) { throw new lxException('could_not_find_file', '', $file); } $tmpdir = lxbackup::createTmpDirIfitDoesntExist($file, false); print_time("create_tmp_dir", "Creating Tmp Directory"); $filename = recursively_get_file($tmpdir, "{$progname}.file"); // KLoxo has to recognize lxadmin's backup file. if (!$filename && $sgbl->isKloxoForRestore()) { $filename = recursively_get_file($tmpdir, "lxadmin.file"); } $rem = unserialize(file_get_contents($filename)); $bugfix = $tmpdir . $progname . ".file"; lxfile_rm($bugfix); $bugfix = $tmpdir . $progname . ".metadata"; lxfile_rm($bugfix); lxfile_tmp_rm_rec($tmpdir); lxfile_rm_rec($tmpdir); if (!$rem) { throw new lxException('backupfile_corrupted', ''); } return $rem; }