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'] ) {
|
|
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
|
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-11 13:55:49 +05:00
|
|
|
|
case 'new_cat': //30.01.2022 - законченный модуль создания/редактирования модуля
|
|
|
|
|
if ( $_POST['input_new_cat_edit_id'] ){//Если приказали редактировать
|
|
|
|
|
//вынимаем из таблицы json, в процессе изменяем его и снова пихаем в базу
|
|
|
|
|
unset( $a );
|
|
|
|
|
$a['id'] = $_POST['input_new_cat_edit_id'];
|
|
|
|
|
$t = $db -> from_j ( $db -> clear_json ( $db -> get_val('pages', $a, 'json' ) ) );
|
|
|
|
|
}
|
|
|
|
|
unset( $_POST['act'] );
|
|
|
|
|
$massiv['tip'] = 'tovarCat';
|
|
|
|
|
$massiv['user_id'] = $_SESSION['user_id'];
|
|
|
|
|
$massiv['t'] = time();
|
|
|
|
|
if ($_POST['parent_id'])
|
|
|
|
|
$massiv['parent'] = $_POST['parent_id'];
|
|
|
|
|
else
|
|
|
|
|
$massiv['parent'] = '0';
|
|
|
|
|
$massiv['txt'] = $_POST['input_new_cat'];
|
|
|
|
|
$massiv['public'] = 1;
|
|
|
|
|
$t['title'] = $_POST['input_new_cat'];
|
|
|
|
|
$t['description'] = $_POST['input_new_cat_description'];
|
|
|
|
|
$t['keywords'] = $_POST['input_new_cat_keywords'];
|
|
|
|
|
$massiv['json'] = $db -> to_j( $t );
|
|
|
|
|
if ( $_POST['input_new_cat_edit_id'] ){//Если приказали редактировать
|
|
|
|
|
$db -> update( 'pages', $_POST['input_new_cat_edit_id'], $massiv );
|
|
|
|
|
}else{
|
|
|
|
|
$db -> add ( 'pages', $massiv );
|
|
|
|
|
}
|
|
|
|
|
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:
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
?>
|