2023-02-23 20:11:22 +05:00
|
|
|
|
<?php
|
|
|
|
|
session_start();
|
|
|
|
|
define( 'MYDIR', $_SERVER['DOCUMENT_ROOT'] ); //Делаем константу со своей директорией
|
|
|
|
|
define( 'SMARTY_DIR', MYDIR . '/api/soft/smarty/3.1.35/libs/' );//цепляем смарти
|
|
|
|
|
@mkdir ( MYDIR . '/template', 0700 );
|
|
|
|
|
@mkdir ( MYDIR . '/template/css', 0700 );
|
|
|
|
|
@mkdir ( MYDIR . '/template/js', 0700 );
|
|
|
|
|
@mkdir ( MYDIR . '/template/inc', 0700 );
|
|
|
|
|
require_once SMARTY_DIR . 'Smarty.class.php';
|
|
|
|
|
$smarty = new Smarty();
|
|
|
|
|
require_once MYDIR . '/set/conf.php'; //цепляем конфиги
|
|
|
|
|
require_once MYDIR . '/api/php/mysql7.php'; //вызываем апи для работы с мускулом
|
|
|
|
|
global $db;
|
|
|
|
|
$db = new MySQL;
|
|
|
|
|
//$db -> connect( $set['bd_host'], $set['bd_user'], $set['bd_pass'], $set['bd_name'] );
|
|
|
|
|
$db -> debug = 1;//логирование в API - 1 - да, 0 нет
|
|
|
|
|
define ( 'TMPDIR', '/tmp/' . $_SERVER['SERVER_NAME'] );//смотрим куда кешировать
|
|
|
|
|
@mkdir ( TMPDIR, 0700 );
|
|
|
|
|
$smarty->template_dir = MYDIR . '/api/mod/';
|
|
|
|
|
$smarty->compile_dir = TMPDIR . '/';
|
|
|
|
|
$smarty->config_dir = MYDIR . '/int/config/';
|
|
|
|
|
$smarty->cache_dir = TMPDIR . '/';
|
|
|
|
|
|
|
|
|
|
#$smarty->config_load(MYDIR . '/api/plugins.conf');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//включаем логирование
|
|
|
|
|
function detect_ip() {
|
|
|
|
|
$ip = false;
|
|
|
|
|
if (isset($_SERVER["HTTP_X_FORWARDED_FOR"]) and preg_match("#^[0-9.]+$#", $_SERVER["HTTP_X_FORWARDED_FOR"])) {
|
|
|
|
|
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
|
|
|
|
|
}
|
|
|
|
|
else if (isset($_SERVER["HTTP_X_REAL_IP"]) and preg_match("#^[0-9.]+$#", $_SERVER["HTTP_X_REAL_IP"])) {
|
|
|
|
|
$ip = $_SERVER["HTTP_X_REAL_IP"];
|
|
|
|
|
}
|
|
|
|
|
else if (preg_match("#^[0-9.]+$#", $_SERVER["REMOTE_ADDR"])) {
|
|
|
|
|
$ip = $_SERVER["REMOTE_ADDR"];
|
|
|
|
|
}
|
|
|
|
|
return $ip;
|
|
|
|
|
}
|
|
|
|
|
define('USER_IP', detect_ip());
|
|
|
|
|
define('SITE', $_SERVER['SERVER_NAME']);
|
|
|
|
|
//собираем настройки....
|
|
|
|
|
$b['mod'] = 'global';
|
|
|
|
|
$db -> get_val( 'settings', $b, 'xml' );
|
|
|
|
|
$xml = $db -> result;
|
|
|
|
|
//print_r($xml);
|
|
|
|
|
require_once MYDIR . '/api/php/parsexml.php';
|
|
|
|
|
$parce -> make_massiv ( $xml );
|
|
|
|
|
$arr = $parce -> res;
|
|
|
|
|
if (!$arr){//создаем дефотные настройки
|
|
|
|
|
include MYDIR . '/set/install/default.php';
|
|
|
|
|
$db -> get_val( 'settings', $b, 'xml' );//заново их читаем
|
|
|
|
|
$xml = $db -> result;
|
|
|
|
|
require_once MYDIR . '/api/php/parsexml.php';
|
|
|
|
|
$parce -> make_massiv ( $xml );
|
|
|
|
|
$arr = $parce -> res;
|
|
|
|
|
}
|
|
|
|
|
foreach ( $arr as $key => $value ) $settings[$key] = $value;
|
|
|
|
|
$smarty->assign('global_settings', $settings);
|
|
|
|
|
define( 'SKIN', SITE );
|
|
|
|
|
define( 'SITE_NAME', $settings['site_name'] );
|
|
|
|
|
define( 'LOGO', @$settings['logo'] );
|
|
|
|
|
define( 'CAPCHA', '<img src="/api/soft/capcha/capcha.php" id="capcha" style="background-image: url(/api/soft/capcha/bg_capcha.png)">' );
|
|
|
|
|
|
|
|
|
|
$smarty->assign('pluguns', MYDIR . '/api/plugins.conf');/*Константа шапки*/
|
|
|
|
|
|
|
|
|
|
//админ-панель
|
|
|
|
|
$smarty->assign('header_admin', MYDIR . '/api/templates/admin/inc/header.html');/*Константа шапки*/
|
|
|
|
|
$smarty->assign('footer_admin', MYDIR . '/api/templates/admin/inc/footer.html');/*Константа подвала*/
|
|
|
|
|
//все остальное
|
|
|
|
|
if (file_exists(MYDIR . '/template/inc/header.html')){
|
|
|
|
|
$smarty->assign('header', MYDIR . '/api/template/header.html');/*Константа шапки*/
|
|
|
|
|
$smarty->assign('mini_admin', MYDIR . '/api/template/inc/admin.html');/*Константа шапки*/
|
|
|
|
|
$smarty->assign('menu', MYDIR . '/api/template/inc/menu.html');/*Константа шапки*/
|
|
|
|
|
$smarty->assign('footer', MYDIR . '/api/template/inc/footer.html');/*Константа подвала*/
|
|
|
|
|
$smarty->assign('modal_login', MYDIR . '/api/template/inc/modal_login.html');/*Константа подвала*/
|
|
|
|
|
$smarty->assign('login_form', MYDIR . '/api/template/inc/login_form.html');/*Константа подвала*/
|
|
|
|
|
$smarty->assign('tovar_modal', MYDIR . '/api/template/inc/tovar_modal.html');
|
|
|
|
|
$smarty->assign('modal_zakaz', MYDIR . '/api/template/inc/modal_zakaz.html');
|
|
|
|
|
$smarty->assign('lk_left', MYDIR . '/api/template/inc/lk_left.html');
|
|
|
|
|
}else{//Убрать 01.10.2020
|
|
|
|
|
$smarty->assign('header', MYDIR . '/api/templates/' . SKIN . '/inc/header.html');/*Константа шапки*/
|
|
|
|
|
$smarty->assign('mini_admin', MYDIR . '/api/templates/' . SKIN . '/inc/admin.html');/*Константа шапки*/
|
|
|
|
|
$smarty->assign('menu', MYDIR . '/api/templates/' . SKIN . '/inc/menu.html');/*Константа шапки*/
|
|
|
|
|
$smarty->assign('footer', MYDIR . '/api/templates/' . SKIN . '/inc/footer.html');/*Константа подвала*/
|
|
|
|
|
$smarty->assign('modal_login', MYDIR . '/api/templates/' . SKIN . '/inc/modal_login.html');/*Константа подвала*/
|
|
|
|
|
$smarty->assign('login_form', MYDIR . '/api/templates/' . SKIN . '/inc/login_form.html');/*Константа подвала*/
|
|
|
|
|
$smarty->assign('tovar_modal', MYDIR . '/api/templates/' . SKIN . '/inc/tovar_modal.html');
|
|
|
|
|
$smarty->assign('modal_zakaz', MYDIR . '/api/templates/' . SKIN .'/inc/modal_zakaz.html');
|
|
|
|
|
$smarty->assign('lk_left', MYDIR . '/api/templates/' . SKIN .'/inc/lk_left.html');
|
|
|
|
|
}
|
|
|
|
|
//выбор модуля
|
|
|
|
|
if ( isset ( $_GET['mod'] ) ){
|
|
|
|
|
define ( 'MOD', @$_GET['mod'] );
|
|
|
|
|
}else{
|
|
|
|
|
if (@$_SESSION['user_id'])
|
|
|
|
|
define ( 'MOD', $settings['default_mod_auth'] );
|
|
|
|
|
else
|
|
|
|
|
define ( 'MOD', $settings['default_mod'] );
|
|
|
|
|
}
|
|
|
|
|
$smarty->assign('sconf_global', MYDIR . '/set/config/global.txt');
|
|
|
|
|
$smarty->assign('sconf', MYDIR . '/set/config/' . MOD . '.txt');
|
|
|
|
|
//print_r($settings);
|
|
|
|
|
//инсталлятор модулей (сделать проверку на установленность
|
|
|
|
|
if (file_exists(MYDIR . '/set/install/' . MOD . '.php'))include MYDIR . '/set/install/' . MOD . '.php';
|
|
|
|
|
//получаем индивидуальный шаблон
|
|
|
|
|
if (file_exists(MYDIR . '/api/templates/' . SKIN . '/inc/' . MOD . '.html'))
|
|
|
|
|
$smarty -> assign( 'template_mod', MYDIR . '/api/templates/' . SKIN . '/inc/' . MOD . '.html');
|
|
|
|
|
|
|
|
|
|
//выбор ИД
|
|
|
|
|
if ( isset ( $_GET['id'] ) )
|
|
|
|
|
define('ID', @$_GET['id']);
|
|
|
|
|
else
|
|
|
|
|
define('ID', 1);
|
|
|
|
|
include MYDIR . '/api/code/' . MOD . '.php';
|
|
|
|
|
if (file_exists(MYDIR . '/api/code/js/' . MOD . '.js'))$smarty->assign('js_mod', '<script src="/api/code/js/' . MOD . '.js"></script>');
|
|
|
|
|
?>
|