-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathproperties.php
More file actions
42 lines (36 loc) · 1.27 KB
/
properties.php
File metadata and controls
42 lines (36 loc) · 1.27 KB
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
37
38
39
40
41
42
<?php
@session_start();
require_once "../src/functions.inc.php";
$token = onedrive_tokenstore::acquire_token();
if (!$token) {
echo "<div>";
echo "<img src='statics/key-icon.png' width='32px' style='vertical-align: middle;'> ";
echo "<span style='vertical-align: middle;'><a href='".onedrive_auth::build_oauth_url()."'>Login with Onedrive</a></span>";
echo "</div>";
} else {
$sd = new onedrive($token);
try {
$response = $sd->get_file_properties($_GET['fileid']);
echo "<h3>".$response['name']."</h3>";
echo "Size: ".round(($response['size']/1024),2)."Kb<br>";
echo "Created: ".$response['created_time']."<br>";
echo "Pre-Signed URL: <a href='".$response['source']."'>Copy Link</a><br>";
echo "Permalink: <a href='".$response['link']."'>Copy Link</a><br><br>";
echo "<div><img src='statics/folder-icon.png' width='32px' style='vertical-align: middle;'> <span style='vertical-align: middle;'><a href='index.php?folderid=".$response['parent_id']."'>Back to containing folder</a></span></div>";
} catch (Exception $e) {
$errc = ($e->getMessage());
echo "Error: ";
switch (substr($errc,-3)) {
case "403":
echo "Unauthorised";
break;
case "404":
echo "Not found";
break;
default:
echo substr($errc,-3);
break;
}
}
}
?>