protected function runUntrustedAction($action) { switch ($action) { case 'backup': include_once 'HTTP/Download.php'; include_once 'Archive/Tar.php'; if (!$this->data_engine->dump(TIP::buildDataPath('dump'))) { TIP::notifyError('backup'); return false; } $tar_file = TIP::buildCachePath($this->id . '-' . TIP::formatDate('date_sql') . '.tar.gz'); $tar_object = new Archive_Tar($tar_file, 'gz'); $result = $tar_object->createModify(TIP::buildDataPath(), '', TIP::buildPath()); unset($tar_object); if ($result !== true) { return false; } HTTP_Download::staticSend(array('file' => $tar_file, 'contenttype' => 'application/x-gzip', 'contentdisposition' => HTTP_DOWNLOAD_ATTACHMENT)); exit; } return null; }
/** * Build a cached path * * Shortcut for building a path prepending the application 'cache_root'. * * @param string|array $varargs A list of partial paths * @return string The constructed path */ public static function buildCachePath() { static $cache_path = null; if (is_null($cache_path)) { $cache_path = TIP::buildPath(TIP_Application::getGlobal('cache_root')); } return TIP::deepImplode(array($cache_path, func_get_args()), DIRECTORY_SEPARATOR); }