2022-12-11 13:55:49 +05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
//проверяем кто мы
|
|
|
|
$access = 0;
|
|
|
|
if ( $_SESSION['dostup'] =='a' ) $access=1;
|
|
|
|
if ( $_SESSION['dostup'] =='u' ) $access=1;
|
|
|
|
if ( $access==0 ) die( "Нет прав" );
|
|
|
|
|
2023-01-02 21:33:36 +05:00
|
|
|
switch( @$_POST['act'] ) {
|
2023-02-23 22:13:18 +05:00
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
23.02.2023
|
|
|
|
Создаем новую категорию
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
case 'new_category':
|
|
|
|
|
|
|
|
echo \DB::add("INSERT INTO `tovar_category` (`title`, `status`, `category`) VALUES (?, ?, ?)", array( $_POST['title'], 1, $_POST['category'] ) );
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2023-01-02 21:33:36 +05:00
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
02.01.2023
|
|
|
|
Сохраняем мета-теги
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
case 'savemeta':
|
2023-01-07 18:55:55 +05:00
|
|
|
if ( $_POST['id'] ) \DB::set("UPDATE `tovar_category` SET `" . $_POST['pole'] . "`=? WHERE `id`=?", array( $_POST['txt'], $_POST['id'] ));
|
2023-01-02 21:33:36 +05:00
|
|
|
break;
|
|
|
|
|
2023-01-07 18:55:55 +05:00
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
02.01.2023
|
|
|
|
Загрузка обложки
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
case 'upload':
|
|
|
|
if ( $_FILES['file']['tmp_name'] ){
|
|
|
|
$dir='img/' . $_SERVER['SERVER_NAME'] . '/tovar_cat';
|
|
|
|
@mkdir($dir, 0700);
|
|
|
|
if ( preg_match( '/[.](jpg)|(jpeg)|(JPG)|(JPEG)$/', $_FILES['file']['name'] ) ){
|
|
|
|
$filename = \core::genpassword(30);
|
|
|
|
$source = $_FILES['file']['tmp_name'];
|
|
|
|
$target = $dir . '/' . $filename . '.jpg';
|
|
|
|
copy( $source, $target );
|
|
|
|
$id=\DB::add("INSERT INTO `tovar_category_img` (`filename`, `tovar_category_id`) VALUES (?, ?)", array($filename, $_SESSION['tmp']));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2023-01-02 21:33:36 +05:00
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
02.01.2023
|
|
|
|
Сохраняем заголовок категории
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
case 'savetitle':
|
|
|
|
if ( $_POST['id'] ) \DB::set( "UPDATE `tovar_category` SET `title`=? WHERE `id`=?", array( $_POST['txt'], $_POST['id'] ) );
|
|
|
|
break;
|
|
|
|
|
2022-12-24 21:12:23 +05:00
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
21.12.2022
|
|
|
|
Обновляем статус категории товара
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
case 'updateStatus':
|
|
|
|
\DB::set("UPDATE `tovar_category` SET `status`=? WHERE `id`=? LIMIT 1", array( $_POST['status'], $_POST['id'] ));
|
|
|
|
break;
|
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
21.12.2022
|
|
|
|
Сохраняет настройки модуля. Вынести в ядро!
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
case 'setSettings':
|
|
|
|
$json=\DB::getValue("SELECT `json` FROM `settings` WHERE `mod`='a_tovar_cat' LIMIT 1");
|
|
|
|
$massiv=\json::from_j($json);
|
|
|
|
$massiv[$_POST['showNoPublic']]=$_POST['val'];
|
|
|
|
$json=\json::to_j($massiv);
|
|
|
|
\DB::set("UPDATE `settings` SET `json`=? WHERE `mod`='a_tovar_cat' LIMIT 1", array( $json ));
|
2022-12-11 13:55:49 +05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'del_page':
|
|
|
|
unset( $_POST['act'] );
|
|
|
|
$db -> del_id( 'pages', $_POST['id'] );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
}
|
|
|
|
?>
|