Exec($sql); echo $DB->LastId(); } } if ($task == 'removelevel') { $value = Tools_Http::Post('value'); $sql='DELETE FROM pricelevels WHERE level_id="'.$_POST['value'].'"'; $res=$DB->Exec($sql); if($res) echo $res; } if ($task=='addCar') { $title = $DB->Escape(Tools_Http::Post('title')); $id = Tools_Http::Post('catid',true); if (!$title) { array_push($errors,'title'); $err_msg = $L->Str('Ievadiet markas nosaukumu!'); } $pic = $_FILES['imgfile']; $pic_file=''; if ($pic['name'] && !sizeof($errors)) { $hash = Tools_Text::getRandomHash(); $thumb_file = $hash.'.jpg'; $dest = WEBPATH.'images/cars/'; $upload = Tools_Filesystem::uploadFile ('imgfile', $dest, $thumb_file); if (!$upload) { array_push($errors,'pic'); $err_msg = $L->Str('Neizdevās ielādēt bildi.'); } else { if (getimagesize($dest.$thumb_file)) { Tools_Image:: imageResize ($dest.$thumb_file,$dest.$thumb_file,90,90,true,100); chmod($dest.$thumb_file,0777); if ($id) { $cat_data = $DB -> getRow('goods_cars',$id); if ($cat_data['icon']) { unlink($dest.$cat_data['icon']); } $DB->Exec("UPDATE goods_cars SET icon = '".$thumb_file."' WHERE id = ".$id); } $pic_file = $thumb_file; } else { unlink ($dest.$thumb_file); array_push($errors, 'imgilfe'); $err_msg = $L->Str('Ielādētais fails nav bilde!'); } } } if (!sizeof($errors)) { $sql = ($id ? "UPDATE":"INSERT INTO")." goods_cars SET title = '".$title."' ".($id?" WHERE id = ".$id:", icon='".$pic_file."'"); $DB -> Exec($sql); //echo 'OK|'.$L->Str('Marka pievienota.').'|document.location.href=document.location.href;window.opener.document.location.href=window.opener.document.location.href;'; ?> Escape(Tools_Http::Post('update_value')); if ($field == 'price' || $field == 'price_2' ) { $value = Tools_Common::formatPrice($value); } $sql= "UPDATE partners SET ".$field." = '".$value."' WHERE id = ".$id; $DB->Exec($sql); echo $value; } if ($task == 'toggle-cat') { $id = Tools_Http::Post('id',true); $state = Tools_Http::Post('state'); $state = $state == 'true' ? 'active' : 'hidden'; $categories = new Content_Categories(); $categories -> setStatus ($id, $state); } if ($task == 'set-field') { $id = Tools_Http::Post('id',true); $field = Tools_Http::Post('field'); $value = $DB->Escape(Tools_Http::Post('value')); $sql = "UPDATE partners SET ".$field." = '".$value."' WHERE id = ".$id; $DB -> Exec($sql); } if ($task == 'addProduct') { $title = $_POST['title']; $descr = $_POST['descr']; $product_id = Tools_Http::Post('itemid', true); $catid = Tools_Http::Post('catid', true); $sdate = explode('.',$_POST['date']); $date = mktime($_POST['start_hour'],$_POST['start_minutes'],00, $sdate['1'] , $sdate['0'], $sdate['2'] ); //$discount = Tools_Http::Post('discount'); //$measure=(int) $_POST['measure']; /* if (!$title) { array_push($errors,'title'); $err_msg = $L->Str('Ievadiet produkta nosaukumu!'); } */ if (!$catid) { array_push($errors,'catid'); $err_msg = $L->Str('Izvēlieties kategoriju!'); } if (sizeof($errors)) { ?> editItem ($title, $descr, $catid,$date,$product_id); ?> Escape(Tools_Http::Post('title')); $group_id = Tools_Http::Post('group_id',true); if (!$title) { array_push($errors, 'title'); $err_msg = $L->Str('Ievadiet nosaukumu!'); } if (empty($errors)) { if ($group_id) { $DB -> Exec("UPDATE properties_groups SET title = '".$title."' WHERE id = ".$group_id); $id - $group_id; } else { $DB -> Exec("INSERT INTO properties_groups SET title = '".$title."' "); $id = $DB->lastId(); } $L->addText ('properties_groups', 'title', $id); echo 'OK|'.$L->Str('Dati saglabāti').'|reloadPage(); window.opener.reloadPage();'; } } */ if ($task == 'addCat') { $title_h = isset($_POST['title']['lv']) ? $_POST['title']['lv'] : $_POST['title']['ru']; $title = $_POST['title']; $sef = $DB -> Escape(Tools_Http::Post('sef')); $catid = Tools_Http::Post('catid', true); $parentid = Tools_Http::Post('parentid', true); //$groupid = Tools_Http::Post('groupid', true); $car = Tools_Http::Post('car', true); // $pic = $_FILES['imgfile']; // echo 'Title:'.$title; $sef = strtolower($sef ? $sef : Tools_Text::cleanString($title_h)); // echo 'sef:'.$sef; /* if (!$title) { array_push($errors,'title'); $err_msg = $L->Str('Ievadiet kategorijas nosaukumu!'); } */ $sef_check = $DB -> GetRow('content_categories', $sef, 'sef'); if (!empty($sef_check)) { if ($sef_check['id'] != $catid) { array_push($errors,'sef'); $err_msg = $L->Str('Kategorija ar šādu nosaukumu jau eksistē!'); } } if (isset($pic['name']) && !sizeof($errors)) { if ($catid) { $GoodsCategories = new Content_Categories(); $cat_data = $GoodsCategories -> getItem($catid); $i_title = $cat_data['title']; } else { $i_title = $title; } $hash = strtolower(Tools_Text :: cleanString ($i_title).'_'.substr(Tools_Text::getRandomHash(), 0, 5)); $thumb_file = $hash.'.jpg'; $dest = WEBPATH.'images/content_category/'; $upload = Tools_Filesystem::uploadFile ('imgfile', $dest, $thumb_file); if (!$upload) { array_push($errors,'pic'); $err_msg = $L->Str('Neizdevās ielādēt bildi.'); } else { if (getimagesize($dest.$thumb_file)) { Tools_Image:: imageResize ($dest.$thumb_file,$dest.$thumb_file,170,120,true,100); chmod($dest.$thumb_file,0777); if ($catid) { if ($cat_data['image']) { unlink($dest.$cat_data['image']); } echo 'Thumb'.$thumb_file; $DB->Exec("UPDATE partners_categories SET image = '".$thumb_file."' WHERE id = ".$catid); } $pic_file = $thumb_file; } else { unlink ($dest.$thumb_file); array_push($errors, 'imgilfe'); $err_msg = $L->Str('Ielādētais fails nav bilde!'); } } } if (sizeof($errors)) { ?> editCategory($title, $sef, $parentid,$pic_file,$catid); //exit(); ?>