Skip to content
Snippets Groups Projects
Commit e798c323 authored by Michiel de Jong's avatar Michiel de Jong
Browse files

renaming core_unhosted app to just unhosted, and cleaning up unused files in it

parent 71205b8b
No related branches found
No related tags found
No related merge requests found
Showing
with 6 additions and 162 deletions
<?php
/**
* ownCloud app for using your OwnCloud on the unhosted web
*
* @author Michiel de Jong
* Some parts are from the files_publiclink app, and thus:
* @copyright 2010 Robin Appelman icewind1991@gmail.com
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
// Init owncloud
require_once('../../lib/base.php');
require_once( 'lib_unhosted.php' );
require( 'template.php' );
// Check if we are a user
if( !OC_USER::isLoggedIn()){
//var_export($_COOKIE);
//var_export($_SESSION);
//die('get a cookie!');
header( "Location: ".OC_HELPER::linkTo( "index.php" ));
exit();
}
OC_APP::setActiveNavigationEntry( "unhosted_web_administration" );
OC_UTIL::addStyle( 'unhosted_web', 'admin' );
OC_UTIL::addScript( 'unhosted_web', 'admin' );
// return template
$tmpl = new OC_TEMPLATE( "unhosted_web", "admin", "admin" );
$tmpl->assign( 'tokens', OC_UnhostedWeb::getAllTokens());
$tmpl->printPage();
?>
<?php
$RUNTIME_NOAPPS=true; //no need to load the apps
require_once '../../../lib/base.php';
require_once '../lib_unhosted.php';
$token=$_GET['token'];
if(OC_User::isLoggedIn()) {
OC_UnhostedWeb::deleteToken($token);
}
?>
<?php
// We send json data
header( "Content-Type: application/jsonrequest" );
header("Access-Control-Allow-Origin: https://myfavouritesandwich.org");
header('Access-Control-Max-Age: 3600');
header('Access-Control-Allow-Methods: OPTIONS, POST');
try {
if($_POST['secret'] && $_POST['userAddress'] && $_POST['dataScope'] && $_POST['secret']=='XRlc2FuZHdpY2gub3JnIiwiZW1haWwiOiJhc2RmYXNkZkB1b') {
// Init owncloud
require_once('../../../lib/base.php');
require_once('../lib_unhosted.php');
$ownCloudDetails = array(
'url' => 'https://myfavouritesandwich.org:444/',
'usr' => $_POST['userAddress'],//this is not necessarily the case, you could also use one owncloud user and many user addresses on it
'pwd' => OC_User::generatePassword(),
);
$storage = array(
'dataScope' => $_POST['dataScope'],
'storageType' => 'http://unhosted.org/spec/dav/0.1',
'davUrl' => 'https://myfavouritesandwich.org:444/apps/unhosted_web/compat.php/'.$ownCloudDetails['usr'].'/unhosted/',
'userAddress' => $_POST['userAddress'],//here, it refers to the user sent to DAV in the basic auth
);
if(OC_User::userExists($ownCloudDetails['usr'])){
$message = 'account reopened';
$result = OC_User::setPassword($ownCloudDetails['usr'], $ownCloudDetails['pwd']);
} else {
$message = 'account created';
$result = OC_User::createUser($ownCloudDetails['usr'], $ownCloudDetails['pwd']);
}
if($result) {
$storage['davToken'] = OC_UnhostedWeb::createDataScope(
'https://myfavouritesandwich.org/',
$ownCloudDetails['usr'], $storage['dataScope']);
echo json_encode(array('ownCloudDetails' => $ownCloudDetails, 'storage' => $storage));
exit();
} else {
echo json_encode( array( "status" => "error", "data" => "couldn't ", "ownCloudDetails" => $ownCloudDetails));
exit();
}
} else {
echo json_encode( array( "status" => "error", "data" => "post not ok"));
}
} catch(Exception $e) {
echo json_encode( array( "status" => "error", "data" => $e));
}
echo json_encode( array( "status" => "error", "data" => array( "message" => "Computer says 'no'" )));
?>
td.path{min-width:200px}
td.expire{width:120px}
\ No newline at end of file
apps/core_unhosted/img/island.png

3.59 KiB

$(document).ready(function() {
$("button.revoke").live('click', function( event ) {
event.preventDefault();
var token=$(this).attr('data-token');
var data="token="+token;
$.ajax({
type: 'GET',
url: 'ajax/deletetoken.php',
cache: false,
data: data,
success: function(){
$('#'+token).remove();
}
});
});
});
<table id='tokenlist'>
<thead>
<tr>
<td class='appUrl'><?php echo $l->t( 'App-Url' ); ?></td>
<td class='userAddress'><?php echo $l->t( 'User-Address' ); ?></td>
<td class='token'><?php echo $l->t( 'Token' ); ?></td>
</tr>
</thead>
<tbody>
<?php foreach($_['tokens'] as $token=>$details):?>
<tr class='token' id='<?php echo $token;?>'>
<td class='appUrl'><?php echo $details['appUrl'];?></td>
<td class='userAddress'><?php echo $details['userAddress'];?></td>
<td class='token'><?php echo $token;?></td>
<td><button class='revoke fancybutton' data-token='<?php echo $token;?>'><?php echo $l->t( 'Revoke' ); ?></button></td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<a href="<?php echo link_to("files_publiclink", "get.php?token=".$_['token']); ?>"><img src="<?php echo image_path("", "actions/go-home.png"); ?>" alt="Root" /></a>
<?php foreach($_["breadcrumb"] as $crumb): ?>
<a href="<?php echo link_to("files_publiclink", "get.php?token=".$_['token']."&path=".$crumb["dir"]); ?>"><?php echo htmlspecialchars($crumb["name"]); ?></a>
<?php endforeach; ?>
\ No newline at end of file
<?php foreach($_["files"] as $file): ?>
<tr>
<td class="selection"><input type="checkbox" /></td>
<td class="filename"><a style="background-image:url(<?php if($file["type"] == "dir") echo mimetype_icon("dir"); else echo mimetype_icon($file["mime"]); ?>)" href="<?php if($file["type"] == "dir") echo link_to("files_publiclink", "get.php?token=".$_['token']."&path=".$file["directory"]."/".$file["name"]); else echo link_to("files_publiclink", "get.php?token=".$_['token']."&path=".$file["directory"]."/".$file["name"]); ?>" title=""><?php echo htmlspecialchars($file["name"]); ?></a></td>
<td class="filesize"><?php echo human_file_size($file["size"]); ?></td>
<td class="date"><?php if($file["type"] != "dir") echo $file["date"]; ?></td>
<td class="fileaction"><a href="" title=""><img src="images/drop-arrow.png" alt="+" /></a></td>
</tr>
<?php endforeach; ?>
\ No newline at end of file
<?php
OC_App::register( array(
'order' => 10,
'id' => 'unhosted',
'name' => 'Unhosted Web' ));
<?xml version="1.0"?>
<info>
<id>core_unhosted</id>
<id>unhosted</id>
<name>Unhosted Web</name>
<description>On websites that allow unhosted accounts, use your owncloud as the storage for your user data</description>
<version>0.1</version>
......
File moved
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment