K
K
Konstantin Malyarov2017-05-22 01:40:14
Vue.js
Konstantin Malyarov, 2017-05-22 01:40:14

Why does the pattern not work in the program?

There is a pattern:

/(\/\/ \[\'administrator_start\'\])(.|\n)*(\/\/ \[\'administrator_end\'\])/

There is text that is taken from a file file_get_contents("./home.php")and read into a string:
// ['administrator_start']
        if ($_SESSION["user_group_short"] == "administrator" && $_SESSION['active'] == 1) {
//
//
//Группа administrator
//
//
            ?>
            <div>
                Администратор
            </div>
            <div id="databoard">
                <?php

                function showTree($folder) {
                    /* Получаем полный список файлов и каталогов внутри $folder */
                    $files = scandir($folder);
                    foreach ($files as $file) {
                        /* Отбрасываем текущий и родительский каталог */
                        if (($file == '.') || ($file == '..')) {
                            continue;
                        }
                        $f0 = $folder . '/' . $file; //Получаем полный путь к файлу
                        /* Если это директория */
                        if (is_dir($f0)) {
                            /* Выводим, делая заданный отступ, название директории */
                            echo "<p>" . translate(iconv(mb_detect_encoding($file, mb_detect_order(), true), "UTF-8", $file)) . "</p>";
                            /* С помощью рекурсии выводим содержимое полученной директории */
                            showTree($f0);
                        } else {
                            /* Если это файл, то просто выводим название файла */
                            $name_page = explode(".", iconv(mb_detect_encoding($file, mb_detect_order(), true), "UTF-8", $file));
                            echo "<a style='text-decoration: none;' href='" . iconv(mb_detect_encoding($f0, mb_detect_order(), true), "UTF-8", $f0) . "'>" . translate($name_page[0]) . "</a> ";
                        }
                    }
                }

                showTree("../pages/" . $_SESSION['user_group_short']);
                ?>
            </div>
            <?php
        }
// ['administrator_end']
// ['insert_body']

The output should be a line // ['insert_body'].
For the League of Sloth: A Quick Check .
Where is the mistake?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Aksentiev, 2018-08-14
@Sanasol

https://github.com/websanova/vue-auth

D
Dmitry Kuznetsov, 2018-08-14
@dima9595

In my opinion, it's easier to do this through Vuex. During authorization, we get the user data, save it in vuex, and then, if necessary, we get it again and save it there.
PS: this option is suitable if you use laravel as Api.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question