p006/index.php

109 lines
4.5 KiB
PHP
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
#namespace anySite;
//Точка входа
define ( 'MYDIR', $_SERVER['DOCUMENT_ROOT'] );
#ini_set('display_errors', 1 );
@mkdir(MYDIR . '/log', 0700);
$start = microtime(true);
$mem_start = memory_get_usage();
## chmod -R 644 *
require_once $_SERVER['DOCUMENT_ROOT'] . '/redirect.php';
@mkdir(MYDIR . '/tmp', 0700);
@mkdir(MYDIR . '/set', 0700);
@mkdir(MYDIR . '/skin', 0700);
require_once $_SERVER['DOCUMENT_ROOT'] . '/set/int.php';
require_once MYDIR . '/api/php/clean.php';
function compress($buffer) {
$buffer = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $buffer);
return $buffer;
}
if (!@$_SESSION['city'] && !@$_SESSION['region'])require_once(MYDIR . '/api/php/geo.php');
//Собираем верхние категории в меню
if ($_SERVER['SERVER_NAME']=='tk-ligat.ru'){
$sql='SELECT * FROM `pages` WHERE `parent` = 0 AND `public` = 1 AND `tip` = "tovarCat"';
$mnu_categories=$db->free_sql($sql);
$smarty->assign('menu_internet_magazin', $mnu_categories);
/* ----------------------------------------------------------------------
18.09.2022
Фикс описаний товаров, чтоб не ебаться с json без особой нужды
---------------------------------------------------------------------- */
$sql = 'SELECT `json`, `id` FROM `pages` WHERE `tip` = "tovar" AND `opisanie` ISNULL AND `json`<> "" LIMIT 1';
//echo $sql . '<br>';
unset( $json_m );
unset( $json );
$json_m = $db -> free_sql( $sql );
$json = $db -> from_j ( $db -> json_fix( $json_m[0]['json'] ) );
unset( $a );
$opis = $json['opisanie'];
if ( !@$opis ) $opis= ' ';
$sql = 'UPDATE `pages` SET `opisanie` = "' . $db->json_prepare($opis) . '", `json`="" WHERE `id` = ' . $json_m[0]['id'];
//echo $sql;
if ($json_m[0]['id'])$db->free_sql($sql);
unset($id);
$sql = 'SELECT `id` FROM `pages` WHERE `tip` = "tovar" AND `txt` LIKE "%Полотенца бума%" AND `public`= "0" LIMIT 1';
//echo $sql . '<br>';
$id_m = $db -> free_sql( $sql );
$id=$id_m[0]['id'];
$sql = 'UPDATE `pages` SET `public` = "1", `parent`="10542" WHERE `id` = ' . $id;
//echo $sql;
if ($id)$db->free_sql($sql);
unset($id);
unset($id_m);
$sql = 'SELECT `id` FROM `pages` WHERE `tip` = "tovar" AND `txt` LIKE "%Бумага туалет%" AND `parent`<>"10543" LIMIT 1';
//echo $sql . '<br>';
$id_m = $db -> free_sql( $sql );
$id=$id_m[0]['id'];
$sql = 'UPDATE `pages` SET `public` = "1", `parent`="10543", "zakazEnable"=1 WHERE `id` = ' . $id;
//echo $sql;
if ($id)$db->free_sql($sql);
}
#if ( BD_TYPE == 'SQLITE3' ) $sql = 'CREATE TABLE IF NOT EXISTS `cart` (`id` INTEGER PRIMARY KEY NOT NULL, `pages_id` INTEGER, `user_id` TEXT,`kolvo` INTEGER, `t` INTEGER, FOREIGN KEY (pages_id) REFERENCES pages(id))';
#if ( BD_TYPE == 'MYSQL' ) $sql = 'CREATE TABLE IF NOT EXISTS `cart` (`id` int(10) NOT NULL AUTO_INCREMENT PRIMARY KEY, `pages_id` int(10) NOT NULL, `user_id` varchar(30) NOT NULL, `kolvo` int(4) NOT NULL, `t` varchar(13) NOT NULL, FOREIGN KEY (`pages_id`) REFERENCES `pages` (`id`) ) ENGINE="InnoDB" COLLATE "utf8_general_ci"';
#$db->free_sql($sql);
unset($a);
//получаем даннные корзины:
if ($_SESSION['user_id'])
$a['user_id']=$_SESSION['user_id'];
else
$a['user_id']=session_id();
$cart=$db->get_massiv('cart', $a, 'id');
$count=count($cart);
for($i=0;$i<$count;$i++){
$page_id=$cart[$i]['pages_id'];
$sql='SELECT pages.id, pages.txt, pages.cena, img.fileName FROM pages, img WHERE pages.id=' . $cart[$i]['pages_id'] . ' AND img.page_id=' . $cart[$i]['pages_id'] . ' LIMIT 1';
$res=$db->free_sql($sql);
$cart[$i]['txt'] = $res[0]['txt'];
$cart[$i]['cena'] = $res[0]['cena'];
$cart[$i]['fileName'] = $res[0]['fileName'];
}
$smarty->assign('cart', $cart);
$smarty->assign('cart_count', $count);
if (file_exists('skin/inc/mod/' . MOD . '/index.html'))
$smarty->display('skin/inc/mod/' . MOD . '/index.html', ID);
else
$smarty->display('api/modules/' . MOD . '/index.html', ID);
#if (MOD=='main' || MOD=='page' || MOD=='page_all')ob_end_flush();
/*if (MOD!='ajax'){
$finish = microtime(true);
$delta = $finish - $start;
echo '<small style="color: gray;">' . memory_get_usage() - $mem_start . ' b. | ' . $delta . ' сек. </small>';
}*/
@exec('php ' . MYDIR . '/php/getHtml.php &');
?>