*/ namespace OCA_Updater; \OCP\JSON::checkAdminUser(); // Url to download package e.g. http://download.owncloud.org/releases/owncloud-4.0.5.tar.bz2 $packageUrl = 'http://owncloud.org/releases/owncloud-latest.zip'; //Package version e.g. 4.0.4 $packageVersion = ''; $updateData = \OC_Updater::check(); if (isset($updateData['version'])) { $packageVersion = $updateData['version']; } if (isset($updateData['url']) && extension_loaded('bz2')) { $packageUrl = $updateData['url']; } if (!$packageVersion) { \OCP\JSON::error(array('msg' => 'Version not found')); exit; } $sourcePath = Downloader::getPackage($packageUrl, $packageVersion); if (!$sourcePath) { \OCP\JSON::error(array('msg' => 'Unable to fetch package')); exit; } $backupPath = Backup::createBackup(); if ($backupPath) { Updater::update($sourcePath, $backupPath); \OCP\JSON::success(array()); } else { \OCP\JSON::error(array('msg' => 'Failed to create backup')); }
<?php /** * ownCloud - Updater plugin * * @author Victor Dubiniuk * @copyright 2014 Victor Dubiniuk victor.dubiniuk@gmail.com * * This file is licensed under the Affero General Public License version 3 or * later. */ namespace OCA\Updater; \OCP\JSON::checkAdminUser(); \OCP\JSON::callCheck(); set_time_limit(0); $request = file_get_contents('php://input'); $decodedRequest = json_decode($request, true); // Downloading new version $packageUrl = isset($decodedRequest['url']) ? $decodedRequest['url'] : ''; $packageVersion = isset($decodedRequest['version']) ? $decodedRequest['version'] : ''; try { Downloader::getPackage($packageUrl, $packageVersion); \OCP\JSON::success(); } catch (\Exception $e) { App::log($e->getMessage()); \OCP\JSON::error(array('message' => $e->getMessage())); }