if (!array_key_exists('type', get_object_vars($message))) { return; } if ($message->type == 'startfile') { $this->filesProcessed++; $this->compressedTotal += $message->content->compressed; $this->uncompressedTotal += $message->content->uncompressed; } } public function __toString() { return __CLASS__; } } // Import configuration masterSetup(); $retArray = array('status' => true, 'message' => null); $enabled = AKFactory::get('kickstart.enabled', false); if ($enabled) { $task = getQueryParam('task'); switch ($task) { case 'ping': // ping task - realy does nothing! $timer = AKFactory::getTimer(); $timer->enforce_min_exec_time(); break; case 'startRestore': AKFactory::nuke(); // Reset the factory // Let the control flow to the next step (the rest of the code is common!!) // Reset the factory
function doAjax() { $ajax = $this->getState('ajax'); switch ($ajax) { // FTP Connection test for DirectFTP case 'testftp': // Grab request parameters $config = array('host' => $this->input->get('host', '', 'none', 2), 'port' => $this->input->get('port', 21, 'int'), 'user' => $this->input->get('user', '', 'none', 2), 'pass' => $this->input->get('pass', '', 'none', 2), 'initdir' => $this->input->get('initdir', '', 'none', 2), 'usessl' => $this->input->get('usessl', 'cmd') == 'true', 'passive' => $this->input->get('passive', 'cmd') == 'true'); // Perform the FTP connection test $test = new AEArchiverDirectftp(); $test->initialize('', $config); $errors = $test->getError(); if (empty($errors)) { $result = true; } else { $result = $errors; } break; case 'restoreFilesPing': case 'restoreFilesStart': case 'restoreFilesStep': case 'restoreFilesFinalize': global $restoration_setup; $restoration_setup = $this->getRestorationParameters(); define('KICKSTART', 1); include_once JPATH_COMPONENT_ADMINISTRATOR . '/restore.php'; akeebaTinyHackForRestorationObserver(); masterSetup(); $retArray = array('status' => true, 'message' => null); switch ($ajax) { case 'restoreFilesPing': // ping task - realy does nothing! $timer = AKFactory::getTimer(); $timer->enforce_min_exec_time(); break; case 'restoreFilesStart': AKFactory::nuke(); // Reset the factory // Reset the factory case 'restoreFilesStep': $config = JFactory::getConfig(); if (version_compare(JVERSION, '3.0', 'ge')) { $tmp_path = $config->get('tmp_path', ''); } else { $tmp_path = $config->getValue('tmp_path', ''); } $override = array('rename_dirs' => array('sql' => rtrim($tmp_path, '/\\') . '/sql')); $engine = AKFactory::getUnarchiver($override); // Get the engine $observer = new RestorationObserver(); // Create a new observer $engine->attach($observer); // Attach the observer $engine->tick(); $ret = $engine->getStatusArray(); if ($ret['Error'] != '') { $retArray['status'] = false; $retArray['done'] = true; $retArray['message'] = $ret['Error']; } elseif (!$ret['HasRun']) { $retArray['files'] = $observer->filesProcessed; $retArray['bytesIn'] = $observer->compressedTotal; $retArray['bytesOut'] = $observer->uncompressedTotal; $retArray['status'] = true; $retArray['done'] = true; } else { $retArray['files'] = $observer->filesProcessed; $retArray['bytesIn'] = $observer->compressedTotal; $retArray['bytesOut'] = $observer->uncompressedTotal; $retArray['status'] = true; $retArray['done'] = false; $retArray['factory'] = AKFactory::serialize(); } break; case 'restoreFilesFinalize': $root = AKFactory::get('kickstart.setup.destdir'); // Remove the sql dump directory $config = JFactory::getConfig(); if (version_compare(JVERSION, '3.0', 'ge')) { $tmp_path = $config->get('tmp_path', ''); } else { $tmp_path = $config->getValue('tmp_path', ''); } $sqldir = rtrim($tmp_path, '/\\') . '/sql'; recursive_remove_directory($sqldir); break; } return $retArray; break; case 'dbRestoreStart': $this->dbRestorationInit(); case 'dbRestore': $result = $this->dbRestore(); break; // Unrecognized AJAX task // Unrecognized AJAX task default: $result = false; break; } return $result; }