<commit_before><?php
if(!_acl::isAllow('product')){
	die("Access denied");
}
unset($parsed_res);
if(isset($GLOBALS['REQAR'][1]) && is_numeric($GLOBALS['REQAR'][1])){
	$id_product = $GLOBALS['REQAR'][1];
}else{
	header('Location: '.$GLOBALS['URL_base'].'404/');
	exit();
}
$dbtree = new dbtree(_DB_PREFIX_.'category', 'category', $db);
$Unit = new Unit();
$products = new Products();
$News = new News();
$Images = new Images();
$specification = new Specification();
$segmentation = new Segmentation();
if($News->GetCommentListById($id_product)){
	$tpl->Assign('list_comment', $News->list);
}
$pops1 = $News->GetComent();
$tpl->Assign('pops1', $pops1);
$tpl->Assign('related_prods_list', $products->GetArrayRelatedProducts($id_product));
$specification->SetListByProdId($id_product);
$tpl->Assign('product_specs', $specification->list);
$specification->SetList();
$tpl->Assign('specs', $specification->list);
$tpl->Assign('unitslist', $Unit->GetUnitsList());
$tpl->Assign('list_segment_types', $segmentation->GetSegmentationType());

if(isset($_GET['upload']) == true){
	$res = $Images->upload($_FILES, $GLOBALS['PATH_product_img'].'original/'.date('Y').'/'.date('m').'/'.date('d').'/');
	echo str_replace($GLOBALS['PATH_root'], '/', $res);
	exit(0);
}
if(isset($_GET['action']) && $_GET['action'] == "update_spec"){
	if($_GET['id_spec_prod'] == ''){
		$specification->AddSpecToProd($_GET, $id_product);
	}else {
		$specification->UpdateSpecsInProducts($_GET);
	}
	header('Location: '.$GLOBALS['URL_base'].'adm/productedit/'.$id_product);
}elseif(isset($_GET['action']) && $_GET['action'] == "delete_spec"){
	$specification->DelSpecFromProd($_GET['id_spec_prod']);
	$products->UpdateProduct(array('id_product'=>$id_product));
	header('Location: '.$GLOBALS['URL_base'].'adm/productedit/'.$id_product);
}
if(isset($_POST['smb']) || isset($_POST['smb_new'])){
	require_once ($GLOBALS['PATH_block'].'t_fnc.php'); // для ф-ции проверки формы
	if(isset($_POST['price']) && $_POST['price'] == ""){
		$_POST['price'] = 0;
	}
	list($err, $errm) = Product_form_validate();
	if(!$err){
		if(isset($_POST['images']) && !empty($_POST['images'])){
			$to_resize = array();
			//Физическое удалание файлов
			if(isset($_POST['removed_images']) && !empty($_POST['removed_images'])){
				foreach($_POST['removed_images'] as $k=>$path){
					if(file_exists($path) && $products->CheckImages($path)){
						$Images->remove($GLOBALS['PATH_root'].'..'.$path);
					}
				}
			}
			//Добавление фото
			foreach($_POST['images'] as $k=>$image){
				if(IsRenameNeeded($image)){
					$to_rename[$k] = $image;
				}else{
					$no_rename[$k] = $image;
				}
			}<commit_msg>Видимость фотографий при добавлении<commit_after><?php
if(!_acl::isAllow('product')){
	die("Access denied");
}
unset($parsed_res);
if(isset($GLOBALS['REQAR'][1]) && is_numeric($GLOBALS['REQAR'][1])){
	$id_product = $GLOBALS['REQAR'][1];
}else{
	header('Location: '.$GLOBALS['URL_base'].'404/');
	exit();
}
$dbtree = new dbtree(_DB_PREFIX_.'category', 'category', $db);
$Unit = new Unit();
$products = new Products();
$News = new News();
$Images = new Images();
$specification = new Specification();
$segmentation = new Segmentation();
if($News->GetCommentListById($id_product)){
	$tpl->Assign('list_comment', $News->list);
}
$pops1 = $News->GetComent();
$tpl->Assign('pops1', $pops1);
$tpl->Assign('related_prods_list', $products->GetArrayRelatedProducts($id_product));
$specification->SetListByProdId($id_product);
$tpl->Assign('product_specs', $specification->list);
$specification->SetList();
$tpl->Assign('specs', $specification->list);
$tpl->Assign('unitslist', $Unit->GetUnitsList());
$tpl->Assign('list_segment_types', $segmentation->GetSegmentationType());

if(isset($_GET['upload']) == true){
	$res = $Images->upload($_FILES, $GLOBALS['PATH_product_img'].'original/'.date('Y').'/'.date('m').'/'.date('d').'/');
	echo str_replace($GLOBALS['PATH_root'], '/', $res);
	exit(0);
}
if(isset($_GET['action']) && $_GET['action'] == "update_spec"){
	if($_GET['id_spec_prod'] == ''){
		$specification->AddSpecToProd($_GET, $id_product);
	}else {
		$specification->UpdateSpecsInProducts($_GET);
	}
	header('Location: '.$GLOBALS['URL_base'].'adm/productedit/'.$id_product);
}elseif(isset($_GET['action']) && $_GET['action'] == "delete_spec"){
	$specification->DelSpecFromProd($_GET['id_spec_prod']);
	$products->UpdateProduct(array('id_product'=>$id_product));
	header('Location: '.$GLOBALS['URL_base'].'adm/productedit/'.$id_product);
}
if(isset($_POST['smb']) || isset($_POST['smb_new'])){
	if(isset($_POST['images_visible'])){
		$_POST['images_visible'][0] = 1;
	}
	require_once ($GLOBALS['PATH_block'].'t_fnc.php'); // для ф-ции проверки формы
	if(isset($_POST['price']) && $_POST['price'] == ""){
		$_POST['price'] = 0;
	}
	list($err, $errm) = Product_form_validate();
	if(!$err){
		if(isset($_POST['images']) && !empty($_POST['images'])){
			$to_resize = array();
			//Физическое удалание файлов
			if(isset($_POST['removed_images']) && !empty($_POST['removed_images'])){
				foreach($_POST['removed_images'] as $k=>$path){
					if(file_exists($path) && $products->CheckImages($path)){
						$Images->remove($GLOBALS['PATH_root'].'..'.$path);
					}
				}
			}
			//Добавление фото
			foreach($_POST['images'] as $k=>$image){
				if(IsRenameNeeded($image)){
					$to_rename[$k] = $image;
				}else{
					$no_rename[$k] = $image;
				}
			}
{'fraction_non_alphanumeric': 0.2506498329001114, 'fraction_numerical': 0.004455997029335313, 'mean_word_length': 7.100751879699248, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2110056', 'n_tokens_mistral': 2079, 'n_tokens_neox': 1994, 'n_words': 252}