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']; $video_link = $_POST['video']; $product_id = Tools_Http::Post('itemid', true); $catid = Tools_Http::Post('catid', true); //$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,$video_link,$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('video_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 Video_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/video_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 video_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(); ?>