Альтернативная ''Шапка'' для JohnCMS - 6.x.x (6)
gi8ri7
#1
Endi "saytda kim bor" sahifasidan foydalanuvchi qaysi sahifada ekanligini ko'rsatish uchun places.lng faylini qo'lda taxrirlashning hojati yo'q deya bizga ДоХтор JohnCMS saytida birqancha kodlarni taqdim etdi .
incfiles/classes/functions.php uchun
]incfiles/classes/functions.php uchun

head.php uchun
2
Kod · PHP103 qator
/**

 * Автозапись в файл 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);

    }

}
Kod · PHP67 qator
<?php

 

const _IN_JOHNCMS = 1;

$dir = explode(DIRECTORY_SEPARATOR, __DIR__);

$headmod = end($dir); # автоопределение папки

$textl = 'Моя страница';

require_once '../incfiles/core.php';

require_once '../incfiles/head.php';

functions::headmod(__FILE__, $headmod, $textl);

 

/*

    Тут код вашей странички

*/

 

require_once '../incfiles/end.php';

?>



Yoki (agar siz parametrlarni kiritishingiz kerak bo'lsa) 



<?php

 

const _IN_JOHNCMS = 1;

$dir = explode(DIRECTORY_SEPARATOR, __DIR__);

$headmod = end($dir); # автоопределение папки

$textl = 'Моя страница с параметрами';

require_once '../incfiles/core.php';

require_once '../incfiles/head.php';

functions::headmod(__FILE__, $headmod, $textl, '?var=value');

 

/*

    Sahifa kodlari

*/

 

require_once '../incfiles/end.php'
Сирожиддин tomonidan tahrirlandi ·
KooL
#2
Buni til paketdan qanday farqi bor? Nabarot ko'p vaqt ketsa kerak bu usulni tanlasak
0
Сирожиддин
#3
Ajalbek, # Ajalbek (01.02.2019 / 18:21)
Buni til paketdan qanday farqi bor? Nabarot ko'p vaqt ketsa kerak bu usulni tanlasak
Автозапись в файл places.lng местоположения пользователя.

headmod va textl ni o'zi yozib boradi.
1
XuSha
#4
functions.phpga kerakli kodni yozdim endi headga shu kodlarni qoysa boldimi boshqa kod kerak emasmi?
0
gi8ri7
#5
XuSha, # XuSha (04.02.2019 / 12:02)
functions.phpga kerakli kodni yozdim endi headga shu kodlarni qoysa boldimi boshqa kod kerak emasmi?
Har bir sahifaning https://uzfor.uz/view.php?act=file&id=1692 kodlari o'rniga
0
Kod · PHP17 qator
<?php

 

const _IN_JOHNCMS = 1;

$dir = explode(DIRECTORY_SEPARATOR, __DIR__);

$headmod = end($dir); # автоопределение папки

$textl = 'Моя страница';

require_once '../incfiles/core.php';

require_once '../incfiles/head.php';

functions::headmod(__FILE__, $headmod, $textl);
tahrirlandi ·
Akbarali
#6
буни ўрнатишга мени ақлим бир оз сустлик қилди ? Балки қунт билан қарамаганим сабаблидур.


Кимдур ишлатиб кўрдими ?
0