Esempio n. 1
0
 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));
     lxfile_tmp_rm_rec($tmpdir);
     if (!$rem) {
         throw new lxException('backupfile_corrupted', '');
     }
     return $rem;
 }
Esempio n. 2
0
 function doCoreRestore($bfile, $param)
 {
     global $gbl, $sgbl, $login, $ghtml;
     $progname = $sgbl->__var_program_name;
     $cprogname = ucfirst($progname);
     $vd = lxbackup::createTmpDirIfitDoesntExist($bfile, true);
     if ($sgbl->isKloxo()) {
         try {
             $file = "{$vd}/{$progname}.file";
             $rem = getObjectFromFileWithThrow($file);
             $ob = $rem->bobject;
         } catch (Exception $e) {
             $file = "{$vd}/lxadmin.file";
             $rem = getObjectFromFileWithThrow($file);
             $ob = $rem->bobject;
         }
     } else {
         $file = "{$vd}/{$progname}.file";
         $rem = getObjectFromFileWithThrow($file);
         $ob = $rem->bobject;
     }
     dprint($ob->getClName());
     dprint($this->getClName());
     if ($ob->getClName() !== $this->getClName()) {
         throw new lxException('objectclassname_doesnt_match', '');
     }
     $gbl->__var_serverlist = $param['switchserverlist'];
     if ($gbl->__var_list_flag) {
         print "Contents of the backfile: Owner: {$ob->nname}.....\n";
     } else {
         print "Restoring backup for {$ob->nname}.....\n";
     }
     try {
         $ob->checkForConsistency(null, $param['_accountselect'], true);
     } catch (Exception $e) {
         lxfile_tmp_rm_rec($vd);
         throw $e;
     }
     // Restore the currenct client's quota. The person who is doing the restoring souldn't able to escape his new quota.
     if ($this->isLogin()) {
         $ob->priv = $this->priv;
         if (isset($this->listpriv)) {
             $ob->listpriv = $this->listpriv;
         }
         if (isset($this->dnstemplate_list)) {
             $ob->dnstemplate_list = $this->dnstemplate_list;
         }
     }
     try {
         if (!$gbl->__var_list_flag) {
             $ob->was();
             foreach ($sgbl->__var_objectrestorelist as $d) {
                 $d->restoreMeUp($vd, $rem->ddate);
             }
         }
     } catch (Exception $e) {
         lxfile_tmp_rm_rec($vd);
         throw $e;
     }
     lxfile_tmp_rm_rec($vd);
 }