-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.php
35 lines (34 loc) · 970 Bytes
/
api.php
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
<?php
$dir = "YOUR_DIRECTORY/";
$ext_to_show = array("pdf","doc","docx","xls","xlsx","txt","pps","odt");// only formats supports in google view api
$target = "_self";
$no_files = "No personal files";
$files_to_show = array();
if ($handle = opendir($dir))
{
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != ".." && is_file($dir.$file))
{
$ext = (pathinfo($dir.$file));
if(in_array(strtolower($ext['extension']), $ext_to_show))
{
$files_to_show[] = $file;
}
}
}
closedir($handle);
}
if(empty($files_to_show))
{
echo $no_files;
}
else
{
sort($files_to_show);
foreach ($files_to_show as $file)
{
echo ' • <a href="http://YOUR_URL/'.$dir. $file.'&embedded=true" target="'. $target. '">'. $file ."</a><br>\n";
}
}
?>