commit
9edf45a324
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 7.7 KiB |
@ -0,0 +1,6 @@ |
||||
<Link |
||||
rel="remoteStorage" |
||||
template="<?php echo WF_BASEURL; ?>/apps/remoteStorage/WebDAV.php/<?php echo WF_USER; ?>/remoteStorage/{category}/"
|
||||
api="WebDAV" |
||||
auth="<?php echo WF_BASEURL; ?>/apps/remoteStorage/auth.php/<?php echo WF_USER; ?>">
|
||||
</Link> |
@ -1,3 +0,0 @@ |
||||
RewriteEngine On |
||||
RewriteBase / |
||||
RewriteRule host-meta$ \/\.well-known\/host-meta\.php [L] |
@ -1,6 +1,51 @@ |
||||
<?php |
||||
$hostMetaHeader = array( |
||||
'Access-Control-Allow-Origin' => '*', |
||||
'Content-Type' => 'application/xml+xrd' |
||||
); |
||||
$appInfoDir = __DIR__; |
||||
$thisAppDir = dirname($appInfoDir); |
||||
$appsDir = dirname($thisAppDir); |
||||
$ownCloudDir = dirname($appsDir); |
||||
@symlink($thisAppDir, $ownCloudDir.'/.well-known'); |
||||
$docRoot = $_SERVER['DOCUMENT_ROOT']; |
||||
try { |
||||
$webRoot = substr(realpath($ownCloudDir), strlen(realpath($docRoot))); |
||||
} catch(Exception $e) { |
||||
// some servers fail on realpath(), let's try it the unsecure way: |
||||
$webRoot = substr($ownCloudDir, strlen($docRoot)); |
||||
} |
||||
$serverName = $_SERVER['SERVER_NAME']; |
||||
$lrddTmpl = 'http'; |
||||
if(isset($_SERVER['HTTPS'])) { |
||||
$lrddTmpl .= 's'; |
||||
} |
||||
$lrddTmpl .= '://' . $serverName . $webRoot . '/apps/user_webfinger/webfinger.php?q={uri}'; |
||||
$hostMetaPath = $docRoot . '/.well-known/host-meta'; |
||||
$hostMetaDir = $docRoot . '/.well-known'; |
||||
$hostMetaContents = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
||||
<XRD xmlns=\"http://docs.oasis-open.org/ns/xri/xrd-1.0\" xmlns:hm=\"http://host-meta.net/xrd/1.0\"> |
||||
<hm:Host xmlns=\"http://host-meta.net/xrd/1.0\">" . $serverName . "</hm:Host> |
||||
<Link rel=\"lrdd\" template=\"" . $lrddTmpl . "\"> |
||||
<Title>Resource Descriptor</Title> |
||||
</Link> |
||||
</XRD>"; |
||||
@mkdir($hostMetaDir); |
||||
$hostMeta = fopen($hostMetaPath, 'w'); |
||||
if(!$hostMeta) { |
||||
die("Could not open " . $hostMetaPath . " for writing, please check permissions!"); |
||||
} |
||||
if(!fwrite($hostMeta, $hostMetaContents, strlen($hostMetaContents))) { |
||||
die("Could not write to " . $hostMetaPath . ", please check permissions!"); |
||||
} |
||||
fclose($hostMeta); |
||||
|
||||
// write custom headers into .htaccess: |
||||
$htaccess = fopen($hostMetaDir . '/.htaccess', 'w'); |
||||
//TODO: check compatibility! |
||||
fwrite($htaccess, "<filesMatch \"^host-meta$\"> |
||||
<ifModule mod_headers.c>\n"); |
||||
foreach($hostMetaHeader as $header => $value) { |
||||
fwrite($htaccess, "Header set " . $header . " \"" . $value . "\"\n"); |
||||
} |
||||
fwrite($htaccess, "</ifModule>\n</filesMatch>"); |
||||
fclose($htaccess); |
||||
|
@ -1 +0,0 @@ |
||||
please run 'a2enmod rewrite' on your server, set 'AllowOverride All' for /var/www in /etc/apache2/sites-enabled/000-default or equivalent, and then run '/etc/init.d/apache2 restart' |
@ -1,16 +0,0 @@ |
||||
<?php |
||||
if($_SERVER['SCRIPT_NAME'] == '/.well-known/host-meta.php') { |
||||
header("Access-Control-Allow-Origin: *"); |
||||
} else { |
||||
header('Please-first: activate'); |
||||
} |
||||
header("Content-Type: application/xrd+xml"); |
||||
echo "<"; |
||||
?> |
||||
?xml version="1.0" encoding="UTF-8"?> |
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0" xmlns:hm="http://host-meta.net/xrd/1.0"> |
||||
<hm:Host xmlns="http://host-meta.net/xrd/1.0"><?php echo $_SERVER['SERVER_NAME'] ?></hm:Host>
|
||||
<Link rel="lrdd" template="http<?php echo (isset($_SERVER['HTTPS'])?'s':''); ?>://<?php echo $_SERVER['SERVER_NAME'] ?>/.well-known/webfinger.php?q={uri}">
|
||||
</Link> |
||||
</XRD> |
||||
|
@ -1,41 +1,71 @@ |
||||
<?php |
||||
if($_SERVER['SCRIPT_NAME'] == '/.well-known/webfinger.php') { |
||||
header("Access-Control-Allow-Origin: *"); |
||||
} else { |
||||
header('Please-first: activate'); |
||||
} |
||||
header("Access-Control-Allow-Origin: *"); |
||||
header("Content-Type: application/xrd+xml"); |
||||
|
||||
/** |
||||
* To include your app in the webfinger XML, add a new script with file name |
||||
* 'webfinger.php' to /apps/yourapp/appinfo/, which prints out the XML parts |
||||
* to be included. That script can make use of the constants WF_USER (e. g. |
||||
* "user"), WF_ID (user@host) and WF_BASEURL (e. g. https://host/owncloud). |
||||
* An example could look like this: |
||||
* |
||||
* <Link |
||||
* rel="myProfile" |
||||
* type="text/html" |
||||
* href="<?php echo WF_BASEURL; ?>/apps/myApp/profile.php?user=<?php echo WF_USER; ?>">
|
||||
* </Link> |
||||
* |
||||
'* but can also use complex database queries to generate the webfinger result |
||||
**/ |
||||
// calculate the documentroot |
||||
// modified version of the one in lib/base.php that takes the .well-known symlink into account |
||||
$DOCUMENTROOT=realpath($_SERVER['DOCUMENT_ROOT']); |
||||
/*$DOCUMENTROOT=realpath($_SERVER['DOCUMENT_ROOT']); |
||||
$SERVERROOT=str_replace("\\",'/',dirname(dirname(dirname(dirname(__FILE__))))); |
||||
$SUBURI=substr(realpath($_SERVER["SCRIPT_FILENAME"]),strlen($SERVERROOT)); |
||||
$WEBROOT=substr($SUBURI,0,-34); |
||||
*/ |
||||
|
||||
require_once('../../lib/base.php'); |
||||
$request = urldecode($_GET['q']); |
||||
if($_GET['q']) { |
||||
$bits = explode('@', $_GET['q']); |
||||
$userName = $bits[0]; |
||||
$reqParts = explode('@', $request); |
||||
$userName = $reqParts[0]; |
||||
$hostName = $reqParts[1]; |
||||
} else { |
||||
$userName = ''; |
||||
$hostName = ''; |
||||
} |
||||
if(substr($userName, 0, 5) == 'acct:') { |
||||
$userName = substr($userName, 5); |
||||
} |
||||
if($userName == "") { |
||||
$id = ""; |
||||
} else { |
||||
$id = $userName . '@' . $hostName; |
||||
} |
||||
if(isset($_SERVER['HTTPS'])) { |
||||
$baseAddress = 'https://'.$_SERVER['SERVER_NAME'].'/apps/remoteStorage/'; |
||||
$baseAddress = 'https://'; |
||||
} else { |
||||
$baseAddress = 'http://'.$_SERVER['SERVER_NAME'].'/apps/remoteStorage/'; |
||||
$baseAddress = 'http://'; |
||||
} |
||||
$baseAddress .= $_SERVER['SERVER_NAME'].OC::$WEBROOT; |
||||
define('WF_USER', $userName); |
||||
define('WF_ID', $id); |
||||
define('WF_BASEURL', $baseAddress); |
||||
echo "<"; |
||||
?> |
||||
?xml version="1.0" encoding="UTF-8"?> |
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0" xmlns:hm="http://host-meta.net/xrd/1.0"> |
||||
<hm:Host xmlns="http://host-meta.net/xrd/1.0"><?php echo $_SERVER['SERVER_NAME'] ?></hm:Host>
|
||||
<Link |
||||
rel="remoteStorage" |
||||
template="<?php echo $baseAddress ?>WebDAV.php/<?php echo $userName ?>/remoteStorage/{category}/"
|
||||
api="WebDAV" |
||||
auth="<?php echo $baseAddress; ?>auth.php/<?php echo $userName ?>"
|
||||
></Link> |
||||
<hm:Host xmlns="http://host-meta.net/xrd/1.0"><?php echo $_SERVER['SERVER_NAME']; ?></hm:Host>
|
||||
<Subject>acct:<?php echo $id ?></Subject>
|
||||
<?php |
||||
$apps = OC_Appconfig::getApps(); |
||||
foreach($apps as $app) { |
||||
if(OC_App::isEnabled($app)) { |
||||
if(is_file(OC::$APPSROOT . '/apps/' . $app . '/appinfo/webfinger.php')) { |
||||
require($app . '/appinfo/webfinger.php'); |
||||
} |
||||
} |
||||
} |
||||
?> |
||||
</XRD> |
||||
|
After Width: | Height: | Size: 725 B |
@ -0,0 +1,26 @@ |
||||
<?php |
||||
|
||||
// only need filesystem apps |
||||
$RUNTIME_APPTYPES=array('filesystem'); |
||||
|
||||
// Init owncloud |
||||
require_once('../../lib/base.php'); |
||||
require_once('../../lib/template.php'); |
||||
|
||||
OC_JSON::checkLoggedIn(); |
||||
|
||||
// Load the files |
||||
$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : ''; |
||||
$mimetype = isset($_GET['mimetype']) ? $_GET['mimetype'] : ''; |
||||
|
||||
// make filelist |
||||
$files = array(); |
||||
foreach( OC_Files::getdirectorycontent( $dir, $mimetype ) as $i ){ |
||||
$i["date"] = OC_Util::formatDate($i["mtime"] ); |
||||
$i['mimetype_icon'] = $i['type'] == 'dir' ? mimetype_icon('dir'): mimetype_icon($i['mimetype']); |
||||
$files[] = $i; |
||||
} |
||||
|
||||
OC_JSON::success(array('data' => $files)); |
||||
|
||||
?> |
Loading…
Reference in new issue