D
D
DANIL KRESTOV2021-06-18 23:11:44
PHP
DANIL KRESTOV, 2021-06-18 23:11:44

409 error on the site, why?

There is a site that is written in smarty.
In the webmaster, the site gives a 409 response and, accordingly, is prohibited from indexing.
Through scientific poke, I found out that if you remove the RewriteRule ^.*$ start.php [L] line from .htacces, then the response code becomes 200, but index.html opens instead of the page I need, which is located in the templates folder. I do not understand at all which way to dig.
setup.php file

<?php
// Добавлять в отчет все PHP ошибки (см. список изменений)
error_reporting(E_ALL);

$_SERVER['PRODAMUS'] = array();

    define('PUBLICSITE', true);
   $_SERVER['PRODAMUS']['SYSTEM_STORAGE_PATH'] = '/var/www/vhosts/site.ru/_storage/';

setlocale(LC_TIME, "ru_RU.cp1251", "ru_RU.CP1251", "ru_RU", 'rus_RUS'); // for date and time formatting with strftime()

// подключаем дополнительные функции
require_once $_SERVER['PRODAMUS']['SYSTEM_STORAGE_PATH'] . "functions.php";
require_once $_SERVER['PRODAMUS']['SYSTEM_STORAGE_PATH'] . "func.xmail.php";

include_once "config.php";
include_once "libs/class.ishop.php";
require_once $_SERVER['PRODAMUS']['SYSTEM_STORAGE_PATH'] . "libs/class.config.ini.php";
require_once $_SERVER['PRODAMUS']['SYSTEM_STORAGE_PATH'] . "libs/class.config.php";
$globals = Config::Config($config_class['config'], $_SERVER['REQUEST_URI'], $config);

// зачиста корзины при необхдимости
// get domain data
$_SERVER['PRODAMUS']['DOMAIN'] = $prodamus->getDomain($_SERVER['SERVER_NAME']);

// no system requests
if (!empty($_SERVER['REQUEST_URI'])) {
    if ('/robots.txt' == $_SERVER['REQUEST_URI']) {
        headers_sent() || header('Content-Type: text/plain');
        if (
            empty($_SERVER['PRODAMUS']['DOMAIN']['_parameter']['robots_txt']['param_value'])
            || !$_SERVER['PRODAMUS']['DOMAIN']['_parameter']['robots_txt']['_is_own_parameter_']
            || empty($_SERVER['PRODAMUS']['DOMAIN']['_parameter']['SE_indexing_allowed']['param_value'])
            || ('yes' !== $_SERVER['PRODAMUS']['DOMAIN']['_parameter']['SE_indexing_allowed']['param_value'])
            || !$_SERVER['PRODAMUS']['DOMAIN']['_parameter']['SE_indexing_allowed']['_is_own_parameter_']
        ) {
            echo 'User-agent: *', PHP_EOL, 'Disallow: /';
        }
        else {
            echo $_SERVER['PRODAMUS']['DOMAIN']['_parameter']['robots_txt']['param_value'];
        }
        exit;
    }
    elseif ('/style.css' == $_SERVER['REQUEST_URI']) {
        headers_sent() || header('Content-Type: text/css');
        if (!empty($_SERVER['PRODAMUS']['DOMAIN']['_parameter']['style_css']['param_value'])) {
            echo $_SERVER['PRODAMUS']['DOMAIN']['_parameter']['style_css']['param_value'];
        }
        exit;
    }
    elseif ('/favicon.ico' == $_SERVER['REQUEST_URI']) {
        $_fp1 = realpath("{$_SERVER['PRODAMUS']['SYSTEM_STORAGE_PATH']}/{$storage_site_folder}/{$_SERVER['PRODAMUS']['DOMAIN']['domain']}/favicon.ico");
        $_fp2 = realpath("{$_SERVER['PRODAMUS']['SYSTEM_STORAGE_PATH']}/{$storage_site_folder}/{$_SERVER['PRODAMUS']['DOMAIN']['system_site']}/favicon.ico");
        if ($_fp1) {
            headers_sent() || header('Content-Type:image/x-icon');
            readfile($_fp1);
        }
        elseif ($_fp2) {
            headers_sent() || header('Content-Type:image/x-icon');
            readfile($_fp2);
        }
        else {
            sendResponseHeaderByCode(404);
            echo 'Not Found';
        }
        exit;
    }
    elseif ('/sitemap.xml' == $_SERVER['REQUEST_URI']) {
        if (empty($_SERVER['PRODAMUS']['DOMAIN']['_parameter']['sitemap_xml']['param_value'])) {
            sendResponseHeaderByCode(404);
            echo 'Not Found';
        }
        else {
            headers_sent() || header('Content-Type: text/xml');
            echo $_SERVER['PRODAMUS']['DOMAIN']['_parameter']['sitemap_xml']['param_value'];
        }
        exit;
    }
}
$prodamus->setSiteId($_SERVER['PRODAMUS']['DOMAIN']['domain_id']);

// set user contacts from COOKIE
$_SERVER['PRODAMUS']['USER'] = array(
    'NAME'  => isset($_COOKIE['_prodamus_username'])  ? $_COOKIE['_prodamus_username']  : '',
    'EMAIL'	=> isset($_COOKIE['_prodamus_useremail']) ? $_COOKIE['_prodamus_useremail'] : '',
    'CITY'  => isset($_COOKIE['_prodamus_usercity'])  ? $_COOKIE['_prodamus_usercity']  : '' /*strval($_SERVER['PRODAMUS']['GEO']['city'])*/,
);

// init Smarty
define('SMARTY_RESOURCE_CHAR_SET', 'Windows-1251');
require_once ($tmp_smarty_path = $_SERVER['PRODAMUS']['SYSTEM_STORAGE_PATH'] . '/libs/smarty/') . 'core.3/Smarty.class.php';

// подключаем массив с описанием и ключевыми словами страниц
# include_once $engine->server_root . "seo.php";
$smarty = new Smarty;
$smarty->cache_dir = $engine->server_root . "templates/cache/";
$smarty->compile_dir = $engine->server_root . "templates/compiled/";
$smarty->template_dir = $engine->server_root . "templates/source/";
$smarty->config_dir    = $tmp_smarty_path . 'configs/';
$smarty->debugging     = false;
$smarty->compile_check = true;
$smarty->allow_php_tag = true;
array_unshift($smarty->plugins_dir, $tmp_smarty_path . 'plugins.core.3/', $tmp_smarty_path . 'plugins/');

$IShop = Ishop::getInstance($prodamus);

$_SERVER['PRODAMUS']['BREADCRUMBS'] = $prodamus->getBreadcrumbs($_SERVER['PRODAMUS']['DOMAIN']['system_site_id'], urldecode($engine->url_normal));

// register objects and vars
$smarty->registerObject('engine',   $engine);
$smarty->assignByRef('engine',      $engine);
$smarty->assignByRef('prodamus',    $prodamus);
$smarty->assign('company', "ООО&nbsp;&laquo;Ober&raquo;");

// add Smarty to list
$globals['objects']['smarty'] = 'smarty';


// cur page info
$_SERVER['PRODAMUS']['PAGE'] = $prodamus->getPageByUrl($_SERVER['PRODAMUS']['DOMAIN']['system_site_id'], preg_replace('~/{2,}~', '/', urldecode($engine->url_normal) . '/'));

$clean_url = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
// check 404
$e404 = false;
// error get data from DB
if (!empty($_SERVER['PRODAMUS']['PAGE']['_errno'])) {
    sendResponseHeaderByCode(409);
}
// page not found
elseif (!$_SERVER['PRODAMUS']['PAGE']['page_id'] && !file_exists(__DIR__.'/templates/source/'.$clean_url)) {
    sendResponseHeaderByCode(404);
    $e404 = true;
} elseif (
    isset($_SERVER['PRODAMUS']['PAGE']['_parameter']['seo_text']['page_url']) &&
    $_SERVER['PRODAMUS']['PAGE']['_parameter']['seo_text']['page_url'] == '/goods/' &&
    strlen($_SERVER['PRODAMUS']['PAGE']) < strlen($clean_url)
) {
    if (!file_exists(__DIR__.'/templates/source/'.$clean_url)) {
        /*$current_url = explode('/', $_SERVER['REQUEST_URI']); // на будущее: если вдруг снова возникнет ошибка/косяк,
        var_dump($current_url);*/                               // то нужно сделать проверку на существование
        sendResponseHeaderByCode(404);                          // этого товара в базе данных.
        $e404 = true;
    }
}
// 404
if ($e404) {
    $_SERVER['PRODAMUS']['BREADCRUMBS_LIMIT_LEVEL'] = 0;
    $_SERVER['PRODAMUS']['BREADCRUMBS_EXTRA'] = array(array('url'=>'/', 'text'=>"404 Not Found",));
    $smarty_main_tpl = 'design_404.tpl';
}

// exec start.php
$engine->IncludeExecutableFile($globals);

if(isset($structure)) {
    $smarty->assign('structure', $structure);
}

if ($smarty_main_tpl) {
    $smarty->loadFilter('output', 'trimwhitespace');
    $smarty->display($smarty_main_tpl);
    if (isset($seo)):
        /*
        foreach ($seo as $seo_key => $seo_item):
            if (preg_match('~^' . $seo_key . '$~is', $engine->uri_normal, $matches)):
                $seo_item_title = $seo_item['page_title'];
                $seo_item_description = $seo_item['page_seo_description'];
                $seo_item_keywords = $seo_item['page_keywords'];
            endif;
        endforeach;
        */

        $page_url = $engine->getModCurUrl();
        foreach($engine->lang_list as $key => $value) {
            if(strripos($engine->getModCurUrl(), '/'.$key) === 0) {
                $page_url = str_replace('/'.$key, "", $engine->getModCurUrl());
                break;
            }
        }
        $page_seo = empty($seo[$page_url]) ? null : $seo[$page_url];

        $seo_item_title = (isset($page_seo['page_title']) && $page_seo['page_title']) ? $page_seo['page_title'] : '';
        $seo_item_description = (isset($page_seo['page_seo_description']) && $page_seo['page_seo_description']) ? $page_seo['page_seo_description'] : '';
        $seo_item_keywords = (isset($page_seo['page_keywords']) && $page_seo['page_keywords']) ? $page_seo['page_keywords'] : '';
    endif;
    // Вывод титлов страниц
    if (isset($smarty->_tpl_vars['page_title'])):
        $smarty->assign('page_title', isset($seo_item_title) ? $seo_item_title . " | " . $smarty->_tpl_vars['page_title'] : $smarty->_tpl_vars['page_title']);
    else:
        $smarty->assign('page_title', isset($seo_item_title) ? $seo_item_title : "");
    endif;
    // Вывод титлов страниц
    if (isset($smarty->_tpl_vars['page_titls'])):
        $smarty->assign('page_titls', isset($seo_item_titls) ? $seo_item_titls . " | " . $smarty->_tpl_vars['page_titls'] : $smarty->_tpl_vars['page_titls']);
    else:
        $smarty->assign('page_titls', isset($seo_item_titls) ? $seo_item_titls : "");
    endif;

}
    $smarty->assign('site_title', $site_title);
    $smarty->assign('page_seo_titls', isset($seo_item_titls) ? $seo_item_titls : "");
    $smarty->assign('page_seo_description', isset($seo_item_description) ? $seo_item_description : "");
    $smarty->assign('page_keywords', isset($seo_item_keywords) ? $seo_item_keywords : "");

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question