/
teremok.php
49 lines (38 loc) · 1.35 KB
/
teremok.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
use infrajs\ans\Ans;
use infrajs\path\Path;
use infrajs\router\Router;
use infrajs\load\Load;
use infrajs\config\Config;
use infrajs\access\Access;
if (!is_file('vendor/autoload.php')) {
chdir('../../../');
require_once('vendor/autoload.php');
Router::init();
}
$ans = array();
$osrc = Ans::GET('src');
if (!$osrc) return Ans::err($ans,'Для работы необходимо передать параметр ?src= до папки с иллюстрациями: '.$osrc);
$src = Path::theme($osrc);
if (!$src) return Ans::err($ans,'Неправильный путь до папки с иллюстрациями: '.$osrc);
$list = Access::cache(__FILE__, function($src){
$list = array();
array_map(function ($file) use (&$list, $src) {
if ($file{0}=='.') return;
$fdata = Load::nameInfo($file);
if (!in_array($fdata['ext'], array('jpg','jpeg','png'))) return;
$list[] = ['image' => $src.Path::toutf($file), 'btnhref' => Load::loadJSON($src.$fdata['name'].'.json')];
}, scandir($src));
return $list;
}, array($src));
$conf = Config::get('teremok');
$count = $conf['count'];
if ($conf['indicators']) {
$ans['indicators'] = true;
} else {
$ans['indicators'] = false;
}
$count = Ans::GET('count','int', $count);
$list = array_slice($list, 0, $count);
$ans['list'] = $list;
return Ans::ret($ans);