1<?php 2if (!defined('DOKU_INC')) define('DOKU_INC', __DIR__ . '/../../../'); 3require_once(DOKU_INC . 'inc/init.php'); 4 5$core = new syntax_plugin_mikioplugin_core(); 6$renderer = new Doku_Renderer_xhtml(); 7 8if (isset($_GET['id'])) { 9 $id = cleanID($_GET['id']); 10 if (auth_quickaclcheck($id) < AUTH_READ) { 11 http_response_code(403); 12 die('Permission denied'); 13 } 14 15 $content = rawWiki($id); 16 preg_match_all('/<carousel[^-item].*?>.*?<\/carousel>/s', $content, $matches); 17 18 $carousel_index = 0; 19 if (isset($_GET['carousel'])) { 20 $carousel_index = (int) $_GET['carousel']; 21 if ($carousel_index < 1 || $carousel_index > count($matches[0])) { 22 die('The page does not have ' . $carousel_index . ' carousels'); 23 } 24 25 $carousel_index--; 26 } else { 27 if (count($matches[0]) <= 0) { 28 die('No carousels where found on the page'); 29 } 30 } 31 32 preg_match_all('/<[^\/].*?>/s', $matches[0][$carousel_index], $tags); 33 foreach ($tags[0] as $tag) { 34 preg_match_all('/([^\r\n\t\f\v<>= \'"]+)(?:=(["\'])?((?:.(?!\2?\s+(?:\S+)=|\2))+[^>])\2?)?/', $tag, $attributes); 35 36 if (count($attributes) > 0) { 37 $tagName = $attributes[1][0]; 38 $tagAttribs = array(); 39 $count = count($attributes[1]); 40 41 for ($i = 1; $i < $count; $i++) { 42 $value = $attributes[3][$i]; 43 if (strlen($value) == 0) { 44 $value = true; 45 } 46 47 $tagAttribs[$attributes[1][$i]] = $value; 48 } 49 50 if (strcasecmp($tagName, 'carousel') == 0) { 51 $core->syntaxRender($renderer, $tagName, '', $tagAttribs, MIKIO_LEXER_ENTER); 52 } else if (strcasecmp($tagName, 'carousel-item') == 0) { 53 $core->syntaxRender($renderer, $tagName, '', $tagAttribs, MIKIO_LEXER_SPECIAL); 54 } 55 } 56 } 57 58 $core->syntaxRender($renderer, 'carousel', '', $tagAttribs, MIKIO_LEXER_EXIT); 59 60 echo '<html lang=en><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><link type="text/css" rel="stylesheet" href="assets/external.css"/><link type="text/css" rel="stylesheet" href="css.php?css=/assets/variables.less,/assets/styles.less"/></head><body id="dokuwiki__content">'; 61 echo $renderer->doc; 62 echo '<script src="../../scripts/jquery/jquery.min.js"></script><script src="script.js"></script>'; 63 echo '</body></html>'; 64} else { 65 die('No page id was set in the url'); 66} 67