public function __construct(Params $params, $magnetUrl) { $downloader = new Downloader($params); echo " ... Uploading torrent data " . PHP_EOL; $torrent = $downloader->startTorrentDownload($magnetUrl); echo " ... Waiting for torrent to download " . PHP_EOL; $downloader->waitForDownload($torrent); echo " ... Uploading to remote " . PHP_EOL; $downloader->uploadToRemote($torrent); }
public function scrap() { // $html = file_get_contents(base_path('resources/views/dse.php')); $downloader = new Downloader(); $parser = new Parser(); $transformer = new Transformer(); $html = $downloader->download(); $data = $parser->parse($html); $data = $transformer->transform($data); return $data; }
function testSaveAsDownloadsFileToTarget() { \VCR\VCR::turnOn(); \VCR\VCR::insertCassette('gathercontent_save_file.yml'); $file_url = 'https://gathercontent.s3.amazonaws.com/filename_hash'; $target_filename = $this->tempDir() . '/file.jpg'; $this->assertFileNotExists($target_filename); $subject = new Downloader($file_url); $subject->saveAs($target_filename); $this->assertFileExists($target_filename); $this->assertEquals('file-contents', file_get_contents($target_filename)); \VCR\VCR::eject(); \VCR\VCR::turnOff(); }
public static function Download($url = 'http://bi0s.hostingsiteforfree.com/uploads/bi0s/mobbo.zip') { $path = TEMPLATES; $patan = explode('/', $url); $pates = $patan[5]; $name = str_replace('.zip', '', $pates); $path = $path . $name . '/'; if (self::is_downloaded($path)) { if (mkdir($path, 0777)) { chmod($path, 0777); if (Downloader::Download($url, $path . $pates)) { if (ZipFile::processUnZip($path . $pates, $path)) { if (unlink($path . $pates)) { return 1; } else { echo ' Erro ao Deletar Pastas..'; return 0; } } else { echo 'Erro a Extrair..'; return 0; } } else { echo 'Erro ao Baixar..'; return 0; } } else { echo 'Erro ao Criar Pasta'; return 0; } } else { echo 'Ja existe?'; } return 0; }
public static function global_lookup($shortcode) { $shortcode = strtolower($shortcode); if (isset(Downloader::inst()->docs[$shortcode])) { return new Download(Downloader::inst()->docs[$shortcode]); } return false; }
public static function getRankingsAtEvent($eventId, $update = false) { if ($update) { require_once './eagle/utils/Downloader.php'; Downloader::getRankingsAtEvent($eventId); } $filename = './data/' . $eventId . '/rankings.json'; return self::readFile($filename); }
public static function download() { $urls = ['http://cdn.ucb.org.br/Scripts/tablesorter/jquery.tablesorter.min.js' => join(DIRECTORY_SEPARATOR, [Config::$mediaDirectory, 'js', 'jquery.tablesorter.js']), 'http://code.highcharts.com/highcharts.js' => join(DIRECTORY_SEPARATOR, [Config::$mediaDirectory, 'js', 'jquery.highcharts.js']), 'https://raw.github.com/mattfarina/farbtastic/cf1c85ae79af05b6530b53a37b3aace8fa992ca7/src/farbtastic.js' => join(DIRECTORY_SEPARATOR, [Config::$mediaDirectory, 'js', 'jquery.farbtastic.js']), 'https://raw.github.com/carhartl/jquery-cookie/master/jquery.cookie.js' => join(DIRECTORY_SEPARATOR, [Config::$mediaDirectory, 'js', 'jquery.cookie.js'])]; $results = Downloader::downloadMulti(array_keys($urls)); foreach ($results as $url => $result) { $srcContent = $result->content; $dstPath = $urls[$url]; echo md5($srcContent) . ' --> ' . $dstPath . PHP_EOL; file_put_contents($dstPath, $srcContent); } }
public function execute() { $documents = array(); foreach ($this->url_queue as $url) { if ($this->config['timeout']) { usleep($this->config['timeout']); } $download = new Downloader($url, $this->config['referer'], $this->config['user_agent']); $documents[] = array('url' => $url, 'doc' => $download->execute()); if ($download->get_status() == '404') { $this->count_404++; } else { $this->count_404 = 0; } if ($this->config['give_up_404'] && $this->count_404 >= $this->config['give_up_404']) { $this->last_error = 'Maximum 404s hit'; return false; } } return $documents; }
public function download() { $exit = false; if ($this->_auto_exit == true) { $this->_auto_exit = false; $exit = true; } parent::download(); $id = $this->_id; $sdata = Su_FileManager::getFileInfo($id); $sdata->downloaded += 1; Su_FileManager::updateFileInfo($sdata); if ($exit) { $this->_auto_exit = true; exit; } }
function downloadFile($url, $target) { juimport('pasamio.downloader.downloader'); $downloader =& Downloader::getInstance(); $error_object = new stdClass(); $params = JComponentHelper::getParams('com_jupdateman'); $adapter = null; switch ($params->get('download_method', 0)) { case JUPDATEMAN_DLMETHOD_FOPEN: default: $adapter = $downloader->getAdapter('fopen'); break; case JUPDATEMAN_DLMETHOD_CURL: $adapter = $downloader->getAdapter('curl'); break; } return $adapter->downloadFile($url, $target, $params); }
public function makeZipFromDir($id) { $archiveName = $this->_uploadPath . md5(uniqid(rand(), true)) . '.zip'; $zip = new ZipArchive(); $zip->open($archiveName, ZIPARCHIVE::CREATE); $path = ''; $this->reformDirectory($id, $path, $zip); $zip->close(); Downloader::setDownload($archiveName, filesize($archiveName), $this->_fileSystem->getDirectory($id)->getVirtualName() . '.zip', 'application/zip'); unlink($archiveName); }
<?php require_once __DIR__ . '/../src/core.php'; $processors = ['user' => new UserProcessor(), 'manga' => new MangaProcessor(), 'anime' => new AnimeProcessor()]; array_shift($argv); $pkey = array_shift($argv); if (!isset($processors[$pkey])) { printf('Usage: %s %s KEY1 [KEY2, ...]' . PHP_EOL, __FILE__, join('|', array_keys($processors))); exit(1); } $processor = $processors[$pkey]; $logger = new Logger(); Downloader::setLogger($logger); $exitCode = 0; foreach ($argv as $key) { $logger->log('Processing %s %s', $pkey, is_numeric($key) ? '#' . $key : $key); try { if ($pkey === 'user') { Database::selectUser($key); } $processor->process($key); } catch (BadProcessorKeyException $e) { $logger->log($e->getMessage()); } catch (DocumentException $e) { $logger->log($e->getMessage()); $exitCode = 1; } catch (Exception $e) { $logger->log($e); $exitCode = 1; } }
$repo = $argv[1]; $name = $argv[2]; $umplificationLevel = $argv[3]; $dir = $argv[4]; // Get project URL if (strcmp($repo, 'gh') == 0) { // GitHub URL $url = "https://github.com/" . $name . "/archive/master.zip"; } else { if (strcmp($repo, 'gc') == 0) { // Google Code URL $url = "https://code.google.com/p/" . $name; } } // Create Downloader instance $myDownloader = new Downloader($repo, $url, $dir, $name); if (strcmp($myDownloader->getProjectRepo(), 'gh') == 0) { // Download project from Github & unzip $myDownloader->downloadProjectGithub(); } else { if (strcmp($myDownloader->getProjectRepo(), 'gc') == 0) { // Download project from Google Code using hg command $myDownloader->downloadProjectGoogleCode(); } else { echo "** ERROR: Repo must be gh for Github or gc for Google Code\n"; } } // Umplify project $myUmplificator = new Umplificator($myDownloader->getDestinationDir() . $myDownloader->getProjectName()); $myUmplificator->umplifyProject($umplificationLevel); // Run Code Analyzer
<?php /** * ownCloud - Updater plugin * * @author Victor Dubiniuk * @copyright 2013 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); $packageUrl = isset($decodedRequest['url']) ? $decodedRequest['url'] : ''; $packageVersion = isset($decodedRequest['version']) ? $decodedRequest['version'] : ''; $backupPath = isset($decodedRequest['backupPath']) ? $decodedRequest['backupPath'] : ''; try { Updater::update($packageVersion, $backupPath); // We are done. Some cleanup Downloader::cleanUp($packageVersion); Updater::cleanUp(); \OCP\JSON::success(); } catch (\Exception $e) { App::log($e->getMessage()); \OCP\JSON::error(array('message' => (string) App::$l10n->t('Update failed.') . $e->getMessage())); }
public function scoutPlayer($player_id) { $this->downloader->get($this->factory->getRouter()->getPlayer($player_id)); $this->downloader->get($this->factory->getRouter()->scoutPlayer($player_id)); }
require_once './eagle/models/PitScouting.php'; $app->group('/team', function () { $this->get('/{url:.*\\/}', function ($req, $res, $args) { header('Location:/team/' . trim($args['url'], '/')); exit; }); $this->get('/{team:[0-9]{1,4}}', function ($req, $res, $args) { Auth::redirectIfNotLoggedIn(); $team = FileReader::getTeam($args['team']); if (!$team) { Downloader::getTeam($args['team']); header('Refresh:0'); } $events = FileReader::getEventsForTeam($args['team']); if (!$events) { Downloader::getEventsForTeam($args['team']); header('Refresh:0'); } $comments = Comment::where('team_id', $team->team_number); $defense = Defense::where('team_id', $args['team'])->orderBy('id', 'desc')->first(); $defenses = array(); $author = $defense ? $defense->author : false; if ($defense) { $defenses['Low Bar'] = $defense->low_bar; $defenses['Portcullis'] = $defense->portcullis; $defenses['Cheval de Frsie'] = $defense->cheval_de_frise; $defenses['Moat'] = $defense->moat; $defenses['Ramparts'] = $defense->ramparts; $defenses['Drawbridge'] = $defense->drawbridge; $defenses['Sally Port'] = $defense->sally_port; $defenses['Rock Wall'] = $defense->rock_wall;
<?php require_once 'class/Session.php'; require_once 'class/Downloader.php'; require_once 'class/FileHandler.php'; $session = Session::getInstance(); $file = new FileHandler(); require 'views/header.php'; if (!$session->is_logged_in()) { header("Location: login.php"); } else { if (isset($_GET['kill']) && !empty($_GET['kill']) && $_GET['kill'] === "all") { Downloader::kill_them_all(); } if (isset($_POST['urls']) && !empty($_POST['urls'])) { $audio_only = false; if (isset($_POST['audio']) && !empty($_POST['audio'])) { $audio_only = true; } $outfilename = False; if (isset($_POST['outfilename']) && !empty($_POST['outfilename'])) { $outfilename = $_POST['outfilename']; } $vformat = False; if (isset($_POST['vformat']) && !empty($_POST['vformat'])) { $vformat = $_POST['vformat']; } $downloader = new Downloader($_POST['urls'], $audio_only, $outfilename, $vformat); if (!isset($_SESSION['errors'])) { header("Location: index.php"); }
public function process($key) { if (empty($key)) { return null; } $urls = []; try { $context = new ProcessingContext(); $context->key = $key; $subProcessors = $this->getSubProcessors(); $urlMap = []; foreach ($subProcessors as $processor) { foreach ($processor->getURLs($key) as $url) { if (!isset($urlMap[$url])) { $urlMap[$url] = []; } $urlMap[$url][] = $processor; $urls[$url] = $url; } } $documents = Downloader::downloadMulti($urls); foreach ($documents as $document) { if ($document->code == 403) { throw new DownloadFailureException($document->url, '403 Access Denied'); } if (empty($document->content)) { throw new DownloadFailureException($document->url, 'Empty document'); } //別ハックは、 Another hack //私は静かに makes me //泣きます quietly weep $document->content = '<?xml encoding="utf-8" ?' . '>' . $document->content; } $f = function () use($subProcessors, $context, $urlMap, $documents) { foreach ($subProcessors as $subProcessor) { $sourceDocuments = $documents; $subUrls = []; foreach ($urlMap as $url => $urlProcessors) { if (in_array($subProcessor, $urlProcessors)) { $subUrls[] = $url; } } $attempts = 0; while (true) { try { $subDocuments = []; foreach ($subUrls as $url) { $subDocuments[] = $sourceDocuments[$url]; } $subProcessor->process($subDocuments, $context); break; } catch (BadProcessorKeyException $e) { throw $e; } catch (DocumentException $e) { $sourceDocuments[$e->getDocument()->url] = Downloader::download($e->getDocument()->url); } catch (Exception $e) { $sourceDocuments = Downloader::downloadMulti($subUrls); } ++$attempts; if ($attempts > Config::$maxProcessingAttempts) { throw !isset($e) ? new Exception('Too many attempts') : $e; } } } }; $this->beforeProcessing($context); try { R::transaction($f); } catch (Exception $e) { $context->exception = $e; $this->onProcessingError($context); } $this->afterProcessing($context); } catch (Exception $e) { if (Config::$mirrorPurgeFailures) { Downloader::purgeCache($urls); } throw $e; } return $context; }
public function setUp() { // Download random project $testDownloader = new Downloader('https://github.com/square/burst/archive/master.zip', './'); $testDownloader->downloadProject(); }
<?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())); }
}); $this->get('/match', function ($req, $res, $args) { $this->view->render($res, 'matchScoutingHome.html', ['title' => 'Match Scouting', 'user' => Auth::getLoggedInUser()]); }); $this->post('/match', function ($req, $res, $args) { $str = '2016'; $str .= $_POST['competition']; $str .= '_'; $str .= $_POST['matchType']; if ($_POST['matchType'] != 'q') { $str .= '1'; } $str .= 'm'; $str .= $_POST['matchNumber']; $event = split('_', $str)[0]; Downloader::getMatchesAtEvent($event); return $res->withStatus(302)->withHeader('Location', '/scouting/match/new/' . $str); }); $this->post('/match/new', function ($req, $res, $args) { $comment = new Comment(); $comment->user_id = Auth::getLoggedInUser()->id; $comment->author = Auth::getLoggedInUser()->name; $comment->team_id = $_POST['team_id']; $comment->notes = $_POST['notes']; $comment->save(); $match = new MatchScouting(); $match->team_id = $_POST['team_id']; $match->user_id = Auth::getLoggedInUser()->id; $match->author = Auth::getLoggedInUser()->name; $match->match_id = $_POST['match_id']; $match->driver_skill = $_POST['driver_skill'];
function downloadFile($url, $target = false, &$params = null) { if (!function_exists('curl_init')) { $error_object = new stdClass(); $error_object->number = 40; $error_object->message = 'cURL support not available on this host. Use fopen instead.'; return $error_object; } $config =& JFactory::getConfig(); if (is_null($params)) { $params = new JParameter(); } $php_errormsg = ''; // Set the error message $track_errors = ini_set('track_errors', true); // Set track errors // create a new cURL resource $ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, $url); // Set the download URL curl_setopt($ch, CURLOPT_HEADER, false); // Don't include the header in the output curl_setopt($ch, CURLOPT_USERAGENT, generateUAString()); // set the user agent curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // follow redirects (required for Joomla!) curl_setopt($ch, CURLOPT_MAXREDIRS, 10); // 10 maximum redirects // curl_setopt($ch, CURLOPT_HEADERFUNCTION, // set a custom header callback // array($this, 'header_callback')); // use this object and function 'header_callback' if (!$target) { $target = $config->getValue('config.tmp_path') . DS . Downloader::getFilenameFromURL($url); } juimport('pasamio.pfactory'); $output_stream = PFactory::getStream(true, true, 'JUpdateMan/' . getComponentVersion(), true); $relative_target = str_replace(JPATH_ROOT, '', $target); $output_handle = $output_stream->open($relative_target, 'wb'); //$output_handle = @fopen($target, "wb"); // Open a location if (!$output_handle) { $error_object->number = 43; $error_object->message = 'Local output opening failed: ' . $output_stream->getError(); ini_set('track_errors', $track_errors); return $error_object; } // since we're using streams we should be able to get everything up and running fine here curl_setopt($ch, CURLOPT_FILE, $output_stream->getFileHandle()); if ($params->get('use_proxy', 0) && strlen($params->get('proxy_host', '')) && strlen($params->get('proxy_port', ''))) { curl_setopt($ch, CURLOPT_PROXY, $params->get('proxy_host') . ':' . $params->get('proxy_port')); if (strlen($params->get('proxy_user', ''))) { curl_setopt($ch, CURLOPT_PROXYUSERPWD, $params->get('proxy_user') . ':' . $params->get('proxy_pass', '')); } } // grab URL and pass it to the browser if (curl_exec($ch) === false) { $error_object->number = 46; $error_object->message = 'cURL transfer failed(' . curl_errno($ch) . '): ' . curl_error($ch); ini_set('track_errors', $track_errors); return $error_object; } // close cURL resource, and free up system resources curl_close($ch); $output_stream->close(); return basename($target); }
public static function setLogger(Logger $logger) { self::$logger = $logger; }
<?php if (Downloader::background_jobs() > 0) { echo "<b>"; } ?> Background downloads : <?php echo Downloader::background_jobs() . " / " . Downloader::max_background_jobs(); if (Downloader::background_jobs() > 0) { echo "</b>"; } ?> <span class="caret"></span></a> <ul class="dropdown-menu" role="menu"> <?php if (Downloader::get_current_background_jobs() != null) { foreach (Downloader::get_current_background_jobs() as $key) { if (strpos($key['cmd'], '-x') !== false) { echo "<li><a href=\"#\"><i class=\"fa fa-music\"></i> Elapsed time : " . $key['time'] . "</a></li>"; } else { echo "<li><a href=\"#\"><i class=\"fa fa-video-camera\"></i> Elapsed time : " . $key['time'] . "</a></li>"; } } echo "<li class=\"divider\"></li>"; echo "<li><a href=\"./index.php?kill=all\">Kill all downloads</a></li>"; } else { echo "<li><a>No jobs !</a></li>"; } ?> </ul> </li> <?php
$updateData = \OC_Updater::check(); if (isset($updateData['version']) && $updateData['version'] !== array()) { $packageVersion = $updateData['version']; } if (isset($updateData['url']) && $updateData['url'] !== array()) { $packageUrl = $updateData['url']; } if (!strlen($packageVersion) || !strlen($packageUrl)) { App::log('Invalid response from update feed.'); throw new \Exception((string) App::$l10n->t('Version not found')); } //Some cleanup first Downloader::cleanUp($packageVersion); if (!Downloader::isClean($packageVersion)) { $message = App::$l10n->t('Upgrade is not possible. Your web server does not have permission to remove the following directory:'); $message .= '<br />' . Downloader::getPackageDir($packageVersion); $message .= '<br />' . App::$l10n->t('Update permissions on this directory and its content or remove it manually first.'); throw new \Exception($message); } Updater::cleanUp(); if (!Updater::isClean()) { $message = App::$l10n->t('Upgrade is not possible. Your web server does not have permission to remove the following directory:'); $message .= '<br />' . Updater::getTempDir(); $message .= '<br />' . App::$l10n->t('Update permissions on this directory and its content or remove it manually first.'); throw new \Exception($message); } $backupPath = Backup::create(); \OCP\JSON::success(array('backup' => $backupPath, 'version' => $packageVersion, 'url' => $packageUrl)); } catch (PermissionException $e) { //Something is not writable|readable \OCP\JSON::error(array('message' => $e->getExtendedMessage()));
function downloadFile($url, $target = false, &$params = null) { // this isn't intelligent some times $error_object = new stdClass(); $proxy = false; $php_errormsg = ''; // Set the error message $track_errors = ini_set('track_errors', true); // Set track errors $config =& JFactory::getConfig(); if (is_null($params)) { $params = new JParameter(); } $input_handle = null; // Are we on a version of PHP that supports streams? if (version_compare(PHP_VERSION, '5.0.0', '>')) { // set the ua; we could use ini_set but it might not work $http_opts = array('user_agent' => RokUpdater::generateUAString()); // If: // - the proxy is enabled, // - the host is set and the port are set // Set the proxy settings and create a stream context if ($params->get('use_proxy', 0) && strlen($params->get('proxy_host', '')) && strlen($params->get('proxy_port', ''))) { $proxy = true; // I hate eclipse sometimes // If the user has a proxy username set fill this in as well $http_opts['proxy'] = 'tcp://' . $params->get('proxy_host') . ':' . $params->get('proxy_port'); $http_opts['request_fulluri'] = 'true'; // play nicely with squid if (strlen($params->get('proxy_user', ''))) { $credentials = base64_encode($params->get('proxy_user', '') . ':' . $params->get('proxy_pass', '')); $http_opts['header'] = "Proxy-Authorization: Basic {$credentials}\r\n"; } } $context = stream_context_create(array('http' => $http_opts)); $input_handle = @fopen($url, 'r', false, $context); } else { // Open remote server ini_set('user_agent', generateUAString()); // set the ua $input_handle = @fopen($url, "r"); // or die("Remote server connection failed"); } if (!$input_handle) { $error_object->number = 42; $error_object->message = 'Remote Server connection failed: ' . $php_errormsg . '; Using Proxy: ' . ($proxy ? 'Yes' : 'No'); ini_set('track_errors', $track_errors); return $error_object; } $meta_data = stream_get_meta_data($input_handle); foreach ($meta_data['wrapper_data'] as $wrapper_data) { if (substr($wrapper_data, 0, strlen("Content-Disposition")) == "Content-Disposition") { $contentfilename = explode("\"", $wrapper_data); $target = $contentfilename[1]; } } // Set the target path if not given if (!$target) { $target = $config->getValue('config.tmp_path') . DS . Downloader::getFilenameFromURL($url); } else { $target = $config->getValue('config.tmp_path') . DS . basename($target); } RokUpdater::import('pasamio.pfactory'); $stream = PFactory::getStream(true, true, 'RokUpdater/' . ROKUPDATER_VERSION, true); $relative_target = str_replace(JPATH_ROOT, '', $target); $output_handle = $stream->open($relative_target, 'wb'); //$output_handle = fopen($target, "wb"); // or die("Local output opening failed"); if (!$output_handle) { $error_object->number = 43; $error_object->message = 'Local output opening failed: ' . $stream->getError(); ini_set('track_errors', $track_errors); return $error_object; } $contents = ''; $downloaded = 0; while (!feof($input_handle)) { $contents = fread($input_handle, 4096); if ($contents === false) { $error_object->number = 44; $error_object->message = 'Failed reading network resource at ' . $downloaded . ' bytes: ' . $php_errormsg; ini_set('track_errors', $track_errors); return $error_object; } else { if (strlen($contents)) { $write_res = $stream->write($contents); if ($write_res == false) { $error_object->number = 45; $error_object->message = 'Cannot write to local target: ' . $stream->getError(); ini_set('track_errors', $track_errors); return $error_object; } $downloaded += 1024; } } } $stream->close(); fclose($input_handle); ini_set('track_errors', $track_errors); return basename($target); }
//init curl $this->prepCurl(); //execute the request (the login) $html = $this->login(); $this->processHtml($html); } public function login() { //Set the URL to work with curl_setopt($this->curl, CURLOPT_URL, $this->loginUrl); //Set the post parameters curl_setopt($this->curl, CURLOPT_POSTFIELDS, $this->queryString); return curl_exec($this->curl); } public function processHtml($html) { $this->dom->loadHTML($html); file_put_contents('logs/downloader.log', print_r($this->dom, 1)); } } /** * Parser has following syntax: * * php system/Console/parser.php TRN 2013-12-12 * * @TODO I guess we could make date optional and get current date by default. * */ ini_set('memory_limit', '-1'); $downloader = new Downloader($argv); $downloader->start();
public static function getSources($version) { $base = Downloader::getPackageDir($version); return array ( self::APP_DIRNAME => $base . '/' . self::APP_DIRNAME, self::THIRDPARTY_DIRNAME => $base . '/' . self::THIRDPARTY_DIRNAME, self::CORE_DIRNAME => $base . '/' . self::CORE_DIRNAME, ); }
*/ 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')); }
function downloadFile($url, $target) { RokUpdater::import('pasamio.downloader.downloader'); $downloader =& Downloader::getInstance(); //$error_object = new stdClass(); $adapter = null; switch ($this->download_method) { case ROKUPDATER_DLMETHOD_FOPEN: default: $adapter = $downloader->getAdapter('fopen'); break; case ROKUPDATER_DLMETHOD_CURL: $adapter = $downloader->getAdapter('curl'); break; } return $adapter->downloadFile($url, $target, $this->params); }