. * */ // Do not load FS ... $RUNTIME_NOSETUPFS = true; OCP\App::checkAppEnabled('remoteStorage'); require_once('Sabre/autoload.php'); require_once('lib_remoteStorage.php'); require_once('oauth_ro_auth.php'); ini_set('default_charset', 'UTF-8'); #ini_set('error_reporting', ''); @ob_clean(); $path = substr($_SERVER["REQUEST_URI"], strlen($_SERVER["SCRIPT_NAME"])); $pathParts = explode('/', $path); if(count($pathParts) == 2 && $pathParts[0] == '') { //TODO: input checking. these explodes may fail to produces the desired arrays: $subPathParts = explode('?', $pathParts[1]); $ownCloudUser = $subPathParts[0]; foreach($_GET as $k => $v) { if($k=='user_address'){ $userAddress=$v; } else if($k=='redirect_uri'){ $appUrlParts=explode('/', $v); $appUrl = $appUrlParts[2];//bit dodgy i guess } else if($k=='scope'){ $categories=$v; } } $currUser = OCP\USER::getUser(); if($currUser == $ownCloudUser) { if(isset($_POST['allow'])) { //TODO: check if this can be faked by editing the cookie in firebug! $token=OC_remoteStorage::createCategories($appUrl, $categories); header('Location: '.$_GET['redirect_uri'].'#access_token='.$token.'&token_type=bearer'); } else if($existingToken = OC_remoteStorage::getTokenFor($appUrl, $categories)) { header('Location: '.$_GET['redirect_uri'].'#access_token='.$existingToken.'&token_type=bearer'); } else { ?> ownCloud

remoteStorage

requests read & write access to your '.$categories[0].''; if(count($categories)==2) { echo ' and '.$categories[1].''; } else if(count($categories)>2) { for($i=1; $i'.$categories[$i].''; } echo ', and '.$categories[$i].''; } } ?>.