Просмотр поста

.
Screamer
$text = ''; // Insert text of post here ...
preg_replace_callback('#\[im\](.*?)\[/im\]#si', 'imagesList', $text);

function imagesList($matches) {
$dir = rtrim(dirname(__FILE__), '\/') . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . $matches[1] . DIRECTORY_SEPARATOR;
if (!is_file($dir . 'cache.json')) {
if (is_dir($dir)) {
$images = array_values(array_diff(scandir($dir), array('.', '..', '.htaccess'))));
// В этом месте можно добавить обработку массива. Например, запилить их в тег <img />
file_put_contents($dir . 'cache.json', json_encode($images));
}
} else {
$images = json_decode(file_get_contents($dir . 'cache.json'));
}
return isset($images) ? implode('<br />', $images) : 'No such file or directory "' . $matches[1] . '"';
}


http://pastebin.com/quNAEDFV