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

.
fcauz

в functions.php что изменилось?
это?

/**
     * Автозапись в файл places.lng местоположения пользователя
     *
     * @param string $file     Локальный путь к файлу
     * @param string $headmod  Название папки с файлом(файлами)
     * @param string $textl    Название заголовка страницы
     * @param string $uri      GET-параметры (если они есть)
     */
    public static function headmod($file, $headmod, $textl, $uri = '')
    {
        $writeToFile = function ($path, $arr, $fname, $uri) {
            file_put_contents($path, $arr);
            header('Location: '. $fname . $uri);
            exit;
        };
        
        $length = 30 - strlen($headmod);
        $spase = html_entity_decode(' ');

        $fname = basename($file);
        $url = $headmod .'/'. $fname . $uri;
        
        $repeat = str_repeat($spase, 3);
        $href = '='. $repeat .'"<a href=\'#home#/'. $url .'\'>'. $textl .'</a>"';
     
        $places = ROOTPATH .'incfiles/languages/ru/places.lng';
        $arrPls = file($places);
        
        $array_result = array_filter(
            $arrPls, 
            function ($item) use ($headmod) {
                return strstr($item, $headmod);
            }
        );

        $arrPls[] = "\r\n". $headmod . str_repeat($spase, $length) . $href;

        if (empty($array_result)) {
            $writeToFile($places, $arrPls, $fname, $uri);
        } else {
            $arrUri = array_map(
                function ($item) {
                    preg_match('~(<a[^>]*>).*</a>~ui', $item, $matches);
                    $pattern = '~<a href=\'#home#/[\w\d]+/?([\w\d-]+\.php?.*)\'>~';
                    return preg_replace($pattern, '$1', $matches[1]);
                },
                $array_result
            );
            
            in_array($fname . $uri, $arrUri) ?: $writeToFile($places, $arrPls, $fname, $uri);
        }
    }