public function resetStages() { apc_CACHE::clear(); }
public function executeJsonRestoreProgress(sfWebRequest $request) { $serial = $request->getParameter('sn'); $apli = new Appliance($serial); $action = $apli->getStage(Appliance::RESTORE_STAGE); switch ($action) { case Appliance::GET_RESTORE: $cache = new apc_CACHE($serial); $total_download = $cache->get(cURL::PROGRESS_DOWNLOAD_TOTAL); $partial_download = $cache->get(cURL::PROGRESS_DOWNLOAD_NOW); $percent = $partial_download / $total_download; $result = array('success' => true, 'action' => $action, 'total_down' => $total_download, 'partial_down' => $partial_download, 'percent' => $percent); break; case Appliance::ARCHIVE_RESTORE: $txt = 'Uncompressing archive...'; $result = array('success' => true, 'txt' => $txt, 'action' => $action); break; case Appliance::DB_RESTORE: $txt = 'Restoring DB...'; $result = array('success' => true, 'txt' => $txt, 'action' => $action); break; case Appliance::VA_ERROR_STORAGE: $result = array('success' => true, 'txt' => 'Storage not restored! Getting actual storage...', 'action' => $action); break; default: $txt = $action; $result = array('success' => true, 'txt' => $txt, 'action' => $action); } if (!$result['success']) { $error = $this->setJsonError($result); return $this->renderText($error); } $json_encoded = json_encode($result); $this->getResponse()->setHttpHeader('Content-type', 'application/json'); return $this->renderText($json_encoded); }