Example #1
0
 static function delete_images($id)
 {
     $row = DB::select('item_image', 'id=' . $id);
     if ($row) {
         if ($row['root_id']) {
             //Ảnh gốc
             DB::delete('item_image', 'root_id=' . $row['root_id']);
         } else {
             DB::delete('item_image', 'id=' . $id);
         }
         //update memcache IMG
         $sql = "SELECT item_id FROM item_image WHERE (id = {$id} OR root_id = {$id}) " . (User::have_permit(ADMIN_IMAGE) ? '' : " AND user_id=" . User::id());
         $re = DB::query($sql);
         if ($re) {
             $item = mysql_fetch_assoc($re);
             if ($item["item_id"]) {
                 require_once ROOT_PATH . 'core/Item.php';
                 Item::get_item_images($item["item_id"], 1);
             }
         }
         //update memcache IMG
         if ($row['img_url']) {
             if (DB::query("UPDATE item SET img_url='' WHERE img_url='" . $row['img_url'] . "'") && MEMCACHE_ON) {
                 $sql = "SELECT * FROM item WHERE img_url = '{$row['img_url']}'";
                 $re = DB::query($sql);
                 while ($item_memcache = mysql_fetch_assoc($re)) {
                     $item_memcache['img_server'] = 0;
                     $item_memcache['img_url'] = '';
                     AZMemcache::do_put("item:" . $item_memcache['id'], $item_memcache);
                 }
             }
             AZLib::ftp_image_delete_file($row['img_url'], $row['img_server']);
         }
     }
 }
Example #2
0
 function ItemDetailForm()
 {
     if (Item::$item['display']) {
         $this->user_info = User::getUser(Item::$item['user_id']);
         if (Item::$item['have_image']) {
             Item::$item['images'] = Item::get_item_images(Item::$item['id']);
             //Item::$item['max_path']	= AZLib::getImageThumbMax(Item::$item['img_url'],'',1,Item::$item['img_server']);
         } else {
             Item::$item['images'] = array();
         }
         CGlobal::$curCategory = Item::$item['category_id'];
         //get current category id from item
         Form::Form('ItemDetailForm');
         //$this->link_header("<script>MM_preloadImages('style/images/add_uncheck.gif','style/images/add_check.gif');</script>");
         $this->link_css('style/ItemDetail.css');
         $this->link_css('style/listItem.css');
         $this->link_css('style/aznet/jquery.lightbox.css');
         $this->link_js('javascript/enbac/item_detail.js');
         $this->link_js('javascript/jquery/jquery.ifixpng2.js');
         $this->link_js('javascript/jquery/lightbox/jquery.lightbox.js');
         $this->link_js('javascript/jquery/packed/jquery.jeditable.js');
         $this->link_js('javascript/jquery/packed/jquery.cookie.js');
         $this->link_js('javascript/enbac/bbcode.js');
         $this->link_js('javascript/ZeroClipboard.js');
         if (User::have_permit(ADMIN_ITEM)) {
             $this->link_css('style/admin.css');
             $this->link_js('javascript/enbac/items_list.js');
             $this->link_js('javascript/jquery/ui.datepicker.js');
             $this->link_css('style/aznet/ui.datepicker.css');
         }
     }
 }
Example #3
0
 function gallery_bulk_delete()
 {
     //Xoá nhiều ảnh
     $arrIDs = explode(',', Url::get('ids'));
     $return = 'fail';
     if (count($arrIDs)) {
         foreach ($arrIDs as $imgID) {
             $image = DB::select('item_image', 'id=' . $imgID . (User::have_permit(ADMIN_IMAGE) ? '' : ' AND user_id=' . User::id()));
             if ($image) {
                 if ($image['img_url']) {
                     AZLib::ftp_image_delete_file($image['img_url'], $image['img_server']);
                     //Xoá ảnh gốc
                     //DB::query("UPDATE item SET img_url='' WHERE img_url='{$image['img_url']}' AND status IN(1,2) " . (User::have_permit(ADMIN_IMAGE) ? '' : ' AND user_id=' . User::id()));
                 }
                 //get Item_id
                 $sql = "SELECT item_id FROM item_image WHERE (id = {$imgID} OR root_id = {$imgID}) " . (User::have_permit(ADMIN_IMAGE) ? '' : " AND user_id=" . User::id());
                 $re = DB::query($sql);
                 if ($re) {
                     $item = mysql_fetch_assoc($re);
                     if ($item["item_id"]) {
                         require_once ROOT_PATH . 'core/Item.php';
                         Item::get_item_images($item["item_id"], 1);
                     }
                 }
                 DB::delete('item_image', '(id=' . $imgID . ' OR root_id=' . $imgID . ')' . (User::have_permit(ADMIN_IMAGE) ? '' : ' AND user_id=' . User::id()));
                 $return = 'success';
             }
         }
     }
     echo $return;
     exit;
 }
Example #4
0
 function mark_sold()
 {
     if (!User::is_login()) {
         echo "not_login";
         exit;
     }
     if (User::is_block()) {
         echo "no_perm";
         exit;
     }
     $img_id = (int) Url::get('img_id');
     $sold = (int) Url::get('sold');
     if ($img_id) {
         $item_image = DB::select("item_image", "id={$img_id}");
         if ($item_image && $item_image['item_id'] && ($item_image['user_id'] == User::id() || User::is_admin())) {
             $item = Item::get_item($item_image['item_id']);
             if ($item && $item['status'] == 1 && $item['state'] == 0) {
                 if ($sold && $item_image['sold'] == 0) {
                     DB::update("item_image", array('sold' => 1), "id={$img_id}");
                 } elseif ($sold == 0 && $item_image['sold'] == 1) {
                     DB::update("item_image", array('sold' => 0), "id={$img_id}");
                 }
                 //update memcache IMG
                 $sql = "SELECT item_id FROM item_image WHERE (id = {$img_id} OR root_id = {$img_id}) " . (User::have_permit(ADMIN_IMAGE) ? '' : " AND user_id=" . User::id());
                 $re = DB::query($sql);
                 if ($re) {
                     $item = mysql_fetch_assoc($re);
                     if ($item["item_id"]) {
                         require_once ROOT_PATH . 'core/Item.php';
                         Item::get_item_images($item["item_id"], 1);
                     }
                 }
                 echo "success";
                 exit;
             }
         }
     } else {
         echo "no_perm";
         exit;
     }
     echo "unsuccess";
     exit;
 }
Example #5
0
 function on_submit()
 {
     AZLib::getCats();
     $sku = AZLib::trimSpace(str_replace("\n", " ", Url::get('sku')));
     ###############################################################################################
     $name = AZLib::trimSpace(str_replace("\n", " ", Url::get('name')));
     mb_internal_encoding("UTF-8");
     $name = mb_strtoupper(mb_substr($name, 0, 1)) . mb_substr($name, 1);
     ###############################################################################################
     ###############################################################################################
     $offer = AZLib::trimSpace(str_replace("\n", " ", Url::get('offer')));
     mb_internal_encoding("UTF-8");
     $offer = mb_strtoupper(mb_substr($offer, 0, 1)) . mb_substr($offer, 1);
     ###############################################################################################
     ###############################################################################################
     $list_brief = AZLib::trimSpace(str_replace("\n", " ", Url::get('list_brief')));
     mb_internal_encoding("UTF-8");
     $list_brief = mb_strtoupper(mb_substr($list_brief, 0, 1)) . mb_substr($list_brief, 1);
     ###############################################################################################
     ###############################################################################################
     //$item_description 	= AZLib::getParam('item_description');
     $item_description = Url::get('item_description');
     $brief = Url::get('brief');
     if (get_magic_quotes_gpc()) {
         $item_description = stripslashes($item_description);
         $brief = stripslashes($brief);
     }
     require_once ROOT_PATH . 'includes/htmLawed.php';
     $config = array('safe' => 1, 'elements' => '*', 'deny_attribute' => 'class, id');
     $spec = 'a = title, href;';
     // The 'a' element can have only these attributes
     $item_description = htmLawed($item_description, $config, $spec);
     $item_description = AZLib::clean_value($item_description);
     $brief = htmLawed($brief, $config, $spec);
     $brief = AZLib::clean_value($brief);
     ###############################################################################################
     $category_id = 0;
     $level_1_catid = 0;
     $first_combo = (int) Url::get('first_combo');
     $second_combo = (int) Url::get('second_combo');
     $price = Url::cdouble(Url::get('price'));
     $price_out = Url::cdouble(Url::get('price_out'));
     $currency_id = (int) Url::get('currency_id', 1);
     $quantity = Url::cdouble(Url::get('quantity', 0));
     if ($quantity < 0) {
         $quantity = 0;
     }
     $item_order = (int) Url::get('item_order');
     $made_in = Url::get('made_in');
     $warranty = Url::get('warranty');
     if (!isset(CGlobal::$currency[$currency_id])) {
         $currency_id = 1;
     }
     $item_category = false;
     if ($first_combo && $second_combo) {
         $category_id = $second_combo;
         $level_1_catid = $first_combo;
         $level_2_catid = $second_combo;
         if (isset(CGlobal::$allCategories[$category_id])) {
             //Kiểm tra sự tồn tai của danh mục
             $item_category = CGlobal::$allCategories[$category_id];
             if (isset(CGlobal::$subCategories[$category_id]) && CGlobal::$subCategories[$category_id] && $item_category['parent_id'] == 0 || $item_category['parent_id'] != $first_combo) {
                 //Nếu danh mục của sản phẩm là danh mục cấp 1 và có danh mục con => chọn lại
                 $this->setFormError('category_id', 'Hãy chọn lại <b>Chủng loại</b> cho sản phẩm!');
             }
         }
     } elseif ($first_combo) {
         //Nếu chọn danh mục cấp 1
         $category_id = $first_combo;
         $level_1_catid = $first_combo;
         $level_2_catid = $first_combo;
         if (isset(CGlobal::$allCategories[$category_id])) {
             //Kiểm tra sự tồn tai của danh mục
             $item_category = CGlobal::$allCategories[$category_id];
             if (isset(CGlobal::$subCategories[$category_id]) && CGlobal::$subCategories[$category_id] && $item_category['parent_id'] == 0) {
                 //Nếu danh mục có danh mục con => Chọn lại!
                 $this->setFormError('category_id', 'Hãy chọn lại <b>Chủng loại</b> cho sản phẩm!');
             } elseif ($item_category['parent_id'] != 0) {
                 //Nếu không fải là danh mục cấp 1
                 $this->setFormError('category_id', 'Hãy chọn lại <b>Chủng loại</b> cho sản phẩm!');
             }
         }
     }
     if (!$item_category) {
         $this->setFormError('category_id', 'Bạn chưa chọn <b>Danh mục</b> cho sản phẩm!');
     }
     /*if($price<=0)
     		{
     			$this->setFormError('price','Với tin rao bán bạn phải nhập <b>Giá</b>');	
     		}
     		else*/
     if ($price > 0) {
         if ($currency_id == 1) {
             $this->checkFormInput("Giá bán", 'price', $price, 'double', false, '', 1, 50000000000);
         } else {
             $this->checkFormInput("Giá bán", 'price', $price, 'double', false, '', 1, 1000000);
         }
     }
     if ($price_out != '' && $price_out != '0') {
         if ($currency_id == 1) {
             $this->checkFormInput("Giá thị trường", 'price_out', $price_out, 'double', false, '', 1, 50000000000);
         } else {
             $this->checkFormInput("Giá thị trường", 'price_out', $price_out, 'double', false, '', 1, 1000000);
         }
     }
     $this->checkFormInput('Tên sản phẩm', 'name', $name, 'str', true, '', 5, 120);
     $this->checkFormInput('Mô tả vắn tắt', 'brief', $brief, 'str', false, '', 15, 500000);
     $this->checkFormInput('Mô tả sản phẩm', 'item_description', $item_description, 'str', true, '', 15, 500000);
     //Check kiểm duyệt
     $status = 1;
     //Cho hiển thị
     $user_item = User::getUser($this->item['user_id']);
     $status = $this->item['status'];
     //Giữ nguyên giá trị
     $have_image_up = false;
     foreach ($this->item_images as $page => $page_images) {
         //trang
         foreach ($page_images as $image) {
             if ($image['img_new_id'] || $image['id']) {
                 $have_image_up = true;
                 break;
             }
         }
     }
     $form_img_server = Url::get('avatar_img_server', 0);
     $this->img_url = Url::get('avatar_img_url', '');
     if (!$this->errNum) {
         $id = $this->item['id'];
         $item_array = array('category_id' => $category_id, 'level_1_catid' => $level_1_catid, 'level_2_catid' => $level_2_catid, 'currency_id' => $currency_id, 'price' => $price, 'price_out' => $price_out, 'sku' => $sku, 'name' => $name, 'offer' => $offer, 'list_brief' => $list_brief, 'brief' => $brief, 'description' => $item_description, 'status' => $status, 'quantity' => $quantity, 'item_order' => $item_order, 'made_in' => $made_in, 'warranty' => $warranty, 'modify_time' => TIME_NOW, 'modify_user_name' => User::user_name(), 'have_image' => (int) (bool) $this->img_url, 'img_server' => $form_img_server, 'img_url' => $this->img_url);
         /*DB::update('item',$item_array,'id='.$id);
         
         			if(MEMCACHE_ON){
         				AZMemcache::do_remove("item:$id");
         			}*/
         $image_err = false;
         //$img_url				='';
         $item_images = array();
         $item_check_images = array();
         $item_insert_temp_images = array();
         $item_insert_images = array();
         $item_update_images = array();
         $item_delete_ids = '';
         $unused_ids = '';
         $img_ids = '';
         $item_have_image = 0;
         //$pos=0;
         foreach ($this->item_images as $page => $page_images) {
             //10 trang
             foreach ($page_images as $image) {
                 if ($image['img_new_id']) {
                     //nếu chọn hoặc thay ảnh mới
                     $item_have_image = 1;
                     $img = array();
                     $title = $image['title'] && $image['title'] != 'Ghi chú ảnh' ? $image['title'] : '';
                     $title = str_replace(array('"'), array('&quot;'), stripslashes($title));
                     $title = $title && !AZLib::checkBadWord($title) ? $title : '';
                     if (isset($this->images[$image['img_new_id']])) {
                         //Nếu chọn mới hoặc thay 1 ảnh đã có
                         if ($this->images[$image['img_new_id']]['position'] == $image['stt']) {
                             //lấy lại chính ảnh cũ
                             if ($title != $this->images[$image['img_new_id']]['title']) {
                                 //Nếu Tên sản phẩm ảnh thay đổi thì cập nhật Tên sản phẩm cho ảnh!
                                 $this->images[$image['img_new_id']]['title'] = addslashes($title);
                                 $item_update_images[$image['img_new_id']] = $this->images[$image['img_new_id']];
                             }
                         } else {
                             //Nếu ảnh được chọn lại ở vị trí khác
                             $img['title'] = addslashes($title);
                             $img['item_id'] = $id;
                             $img['img_server'] = $this->images[$image['img_new_id']]['img_server'];
                             $img['img_url'] = $this->images[$image['img_new_id']]['img_url'];
                             $img['root_id'] = $this->images[$image['img_new_id']]['root_id'];
                             $img['time'] = $this->images[$image['img_new_id']]['time'];
                             $img['user_id'] = $this->images[$image['img_new_id']]['user_id'];
                             $img['user_name'] = $this->images[$image['img_new_id']]['user_name'];
                             $img['item_id'] = $id;
                             $img['position'] = $image['stt'];
                             if ($image['img_del_id'] && isset($this->images[$image['img_del_id']])) {
                                 //Loại bỏ ảnh cũ
                                 if ($this->images[$image['img_del_id']]['root_id']) {
                                     $item_delete_ids .= ($item_delete_ids ? ',' : '') . (int) $image['img_del_id'];
                                 } else {
                                     $unused_ids .= ($unused_ids ? ',' : '') . (int) $image['img_del_id'];
                                 }
                             }
                             if (!$img['root_id']) {
                                 $img['root_id'] = $image['img_new_id'];
                             }
                             $item_insert_images[$image['img_new_id']] = $img;
                         }
                     } else {
                         $img_ids .= ($img_ids ? ',' : '') . $image['img_new_id'];
                         $img['title'] = addslashes($title);
                         $img['item_id'] = $id;
                         $img['img_server'] = $image['img_server'];
                         $img['img_url'] = '';
                         $img['root_id'] = 0;
                         $img['time'] = TIME_NOW;
                         $img['user_id'] = $this->item['user_id'];
                         $img['user_name'] = $this->item['user_name'];
                         $img['item_id'] = $id;
                         $img['position'] = $image['stt'];
                         if ($image['img_del_id'] && isset($this->images[$image['img_del_id']])) {
                             //Loại bỏ ảnh cũ
                             if ($this->images[$image['img_del_id']]['root_id']) {
                                 $item_delete_ids .= ($item_delete_ids ? ',' : '') . (int) $image['img_del_id'];
                             } else {
                                 $unused_ids .= ($unused_ids ? ',' : '') . (int) $image['img_del_id'];
                             }
                         }
                         if (!isset($item_images[$image['img_new_id']])) {
                             $item_images[$image['img_new_id']] = $img;
                         } else {
                             $img['root_id'] = $image['img_new_id'];
                             $item_insert_temp_images[$image['img_new_id']] = $img;
                             //Đúp bản ghi trong trường hợp 1 ảnh được chọn tại nhiều vị trí
                         }
                     }
                 } elseif ($image['id'] && $image['id'] == $_POST['image_deleted'][$image['stt']]) {
                     //Loại bỏ ảnh
                     if ($this->images[$image['id']]['root_id']) {
                         $item_delete_ids .= ($item_delete_ids ? ',' : '') . (int) $image['id'];
                     } else {
                         $unused_ids .= ($unused_ids ? ',' : '') . (int) $image['id'];
                     }
                 } elseif ($image['id'] && $_POST['image_title'][$image['stt']]) {
                     $item_have_image = 1;
                     $title = $_POST['image_title'][$image['stt']] != 'Ghi chú ảnh' ? $_POST['image_title'][$image['stt']] : '';
                     $title = str_replace(array('"'), array('&quot;'), stripslashes($title));
                     $title = $title && !AZLib::checkBadWord($title) ? $title : '';
                     if ($title != $this->images[$image['id']]['title']) {
                         //Nếu Tên sản phẩm ảnh thay đổi thì cập nhật Tên sản phẩm cho ảnh!
                         $this->images[$image['id']]['title'] = addslashes($title);
                         $item_update_images[$image['id']] = $this->images[$image['id']];
                     }
                 } else {
                     $item_have_image = 1;
                 }
             }
         }
         if ($img_ids) {
             //$re=DB::query('SELECT id, item_id, img_server, img_url, time FROM item_image WHERE id IN('.$img_ids.') AND user_id='.$this->item['user_id']);
             $re = DB::query('SELECT id, item_id, user_id, img_server, img_url, time FROM item_image WHERE id IN(' . $img_ids . ')');
             if ($re) {
                 while ($img = mysql_fetch_assoc($re)) {
                     if ($img['user_id'] == $this->item['user_id']) {
                         if (isset($item_insert_temp_images[$img['id']])) {
                             $item_insert_temp_images[$img['id']]['img_server'] = $img['img_server'];
                             $item_insert_temp_images[$img['id']]['img_url'] = $img['img_url'];
                             $item_insert_temp_images[$img['id']]['root_id'] = $img['id'];
                             $item_insert_temp_images[$img['id']]['time'] = $img['time'];
                             $item_insert_images[] = $item_insert_temp_images[$img['id']];
                         }
                         $item_images[$img['id']]['time'] = $img['time'];
                         $item_images[$img['id']]['img_url'] = $img['img_url'];
                         if ($img['item_id']) {
                             //Đã có item_id rồi, đúp bản ghi
                             $image = $item_images[$img['id']];
                             if ($img['root_id']) {
                                 $image['root_id'] = $img['root_id'];
                             } else {
                                 $image['root_id'] = $img['id'];
                             }
                             $item_insert_images[] = $image;
                         } else {
                             //Chưa có item_id, cập nhật
                             $img['item_id'] = $id;
                             $item_update_images[$img['id']] = $item_images[$img['id']];
                         }
                     }
                 }
             }
         }
         if ($item_insert_images) {
             $inser_sql = '';
             foreach ($item_insert_images as $item_image) {
                 $inser_sql .= ($inser_sql ? "," : "") . "\r\n\t\t\t\t\t\t('" . addslashes($item_image['title']) . "',\r\n\t\t\t\t\t\t'" . $item_image['position'] . "','" . $item_image['item_id'] . "','" . $item_image['img_server'] . "','" . $item_image['img_url'] . "','" . $item_image['root_id'] . "',\r\n\t\t\t\t\t\t'" . $item_image['time'] . "','" . $item_image['user_id'] . "','" . $item_image['user_name'] . "')";
             }
             $inser_sql = "INSERT INTO `item_image` (`title`,`position`,`item_id`,`img_server`,`img_url`,`root_id`,`time`,`user_id`,`user_name`) \r\n\t\t\t\t\t\t\tVALUES " . $inser_sql;
             DB::query($inser_sql);
         }
         if ($item_update_images) {
             foreach ($item_update_images as $img_id => $item_image) {
                 if (!DB::update('item_image', $item_image, 'id=' . $img_id)) {
                     $image_err = true;
                 }
             }
         }
         //if($item_delete_ids && !DB::delete('item_image','id IN('.$item_delete_ids.') AND user_id='.$this->item['user_id'].' AND root_id!=0')){
         if ($item_delete_ids && !DB::delete('item_image', 'id IN(' . $item_delete_ids . ') AND root_id!=0')) {
             $image_err = true;
         }
         if ($unused_ids && !DB::update('item_image', array('item_id' => '0', 'title' => '', 'position' => '0'), 'id IN(' . $unused_ids . ') AND user_id=' . $this->item['user_id'] . ' AND root_id=0')) {
             $image_err = true;
         }
         //$main_img = DB::select('item_image','item_id='.$id.' AND user_id='.$this->item['user_id'].' ORDER BY position ASC');
         $main_img = DB::select('item_image', 'item_id=' . $id . ' ORDER BY position ASC');
         if ($main_img) {
             $img_url = $main_img['img_url'];
             $i_server = $main_img['img_server'];
         } else {
             $img_url = '';
             $i_server = 0;
         }
         if ($item_insert_images || $item_update_images || $item_delete_ids || $unused_ids) {
             Item::get_item_images($id, 1);
         }
         //tuannk 2010.07.26
         //end tuannk 2010.07.26
         /*if($this->img_url == '' && $img_url !='' )
         		{
         			DB::update('item',array( 'img_server'=>$i_server, 'img_url'=>$img_url,'have_image'=>1),'id='.$id);
         		}
         		elseif($item_have_image){
         			DB::update('item',array( 'have_image'=>1),'id='.$id);
         		}*/
         ##############################################################################
         #Filters
         $filters = Url::get('filter');
         $filter_search = "";
         $filter_ids = "";
         foreach ($filters as $fgid => $fils) {
             foreach ($fils as $fid) {
                 $filter_search .= ($filter_search != '' ? " " : '') . "g{$fgid}f{$fid}f";
                 $filter_ids .= ($filter_ids != '' ? "," : '') . $fid;
             }
         }
         #Filters
         ##############################################################################
         $item_array['filter_search'] = $filter_search;
         $item_array['filter_ids'] = $filter_ids;
         if ($this->img_url == '' && $img_url != '') {
             $item_array['img_server'] = $i_server;
             $item_array['img_url'] = $img_url;
             $item_array['have_image'] = 1;
         } elseif ($item_have_image) {
             $item_array['have_image'] = 1;
         }
         //DB::update('item',array( 'have_image'=>1),'id='.$id);
         DB::update('item', $item_array, 'id=' . $id);
         if (MEMCACHE_ON) {
             AZMemcache::do_remove("item:{$id}");
         }
         if (Url::get('ref')) {
             Url::redirect("manage_item");
         } else {
             Url::redirect("item_detail", array("id" => $id));
         }
     }
 }
Example #6
0
 function insert_sub_image_payment()
 {
     $img_id = Url::get('image_id');
     $code_emb = Url::get('url_data');
     $main_item_id = Url::get('main_item_id');
     $embed_index = Url::get('embed_index');
     if (empty($code_emb) || $code_emb == "undefined") {
         $code_emb = "";
         DB::query("UPDATE `item_image` SET des = '' WHERE id={$img_id}");
     } else {
         if (strlen(strstr($code_emb, '<a href="https://sohapay.com')) > 0 && strlen(strstr($code_emb, '<img')) > 0) {
             $str_start = strpos($code_emb, '<a href="https://sohapay.com');
             $main_str = substr($code_emb, $str_start);
             $sub_str = split("</a>", $main_str);
             $code_emb = $sub_str[0] . "</a>";
             $patt = '<a href="https://sohapay.com';
             $res = DB::select('item_image', "id={$img_id}");
             $str = split($patt, $res['des']);
             $des_new = $str[0] . $code_emb;
             DB::query("UPDATE `item_image` SET des = '" . $des_new . "' WHERE id={$img_id}");
             /* $item_memcache['reply_count']=1000;
                if (MEMCACHE_ON) {
                    eb_memcache::do_put("item:$main_item_id", $item_memcache);
                    echo "ngannv";
                }*/
         } else {
             DB::query("UPDATE `item_image` SET des = '' WHERE id={$img_id}");
         }
     }
     Item::$item['id'] = $main_item_id;
     Item::get_item_images($main_item_id, 1);
 }