summaryrefslogtreecommitdiffstats
path: root/files/ajax/list.php
blob: 4694f8428323648624d0cb176be210b4c1d2809c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php

// Init owncloud
require_once('../../lib/base.php');

// We send json data
header( "Content-Type: application/jsonrequest" );

// Check if we are a user
if( !OC_USER::isLoggedIn()){
	echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" )));
	exit();
}

// Load the files
$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : '';

$files = array();
foreach( OC_FILES::getdirectorycontent( $dir ) as $i ){
	$i["date"] = date( $CONFIG_DATEFORMAT, $i["mtime"] );
	$files[] = $i;
}

// Make breadcrumb
$breadcrumb = array();
$pathtohere = "/";
foreach( explode( "/", $dir ) as $i ){
	if( $i != "" ){
		$pathtohere .= "$i/";
		$breadcrumb[] = array( "dir" => $pathtohere, "name" => $i );
	}
}

echo json_encode( array( "status" => "success", "data" => array( "files" => $files, "breadcrumb" => $breadcrumb )));

?>