function on_submit() { $user_update = array(); $full_name = Url::get('full_name'); $user_name = Url::get('register_user_name'); $mobile_phone = AZLib::trimSpace(Url::get('mobile_phone')); $home_phone = AZLib::trimSpace(Url::get('home_phone')); $gender = (int) Url::get('gender'); $yahoo_id = AZLib::trimSpace(Url::get('yahoo_id')); $skype_id = AZLib::trimSpace(Url::get('skype_id')); $address = AZLib::trimSpace(Url::get('address')); $website = AZLib::trimSpace(Url::get('website')); $this->checkFormInput('Tên đầy đủ', 'full_name', $full_name, 'str', false, '', 0, 50); $this->checkFormInput('Điện thoại di động', 'mobile_phone', $mobile_phone, 'str', false, '', 0, 50); $this->checkFormInput('Điện thoại bàn', 'home_phone', $home_phone, 'str', false, '', 0, 50); $change_pass = 0; $change_mail = 0; if (User::is_root() && (User::id() == 1 || $this->user['id'] != 1)) { $email = Url::get('email'); $password = AZLib::trimSpace(Url::get('register_password')); $confirm_password = AZLib::trimSpace(Url::get('confirm_password')); if ($password && User::encode_password($password) != $this->user['password']) { //Có nhập pass mới khác pass cũ $this->checkFormInput('Mật khẩu truy cập', 'register_password', $password, 'str', true, '', 6, 50); $change_pass = 1; if ($password != $confirm_password) { $this->setFormError('confirm_password', "Nhập lại Mật khẩu truy cập không khớp!"); } } if ($email && $email != $this->user['email']) { //Có nhập email mới khác email cũ $this->checkFormInput('Email', 'email', $email, 'email', true, '', 6, 50); $change_mail = 1; } } if ($mobile_phone && !AZLib::is_mobile($mobile_phone)) { $mobile_phone = ""; } if (!$this->errNum) { if ($change_mail && DB::exists('SELECT id FROM `user` WHERE `email`="' . $email . '" AND id!=' . $this->user['id'])) { $this->setFormError('email', "<b>Email</b> bạn chọn đã tồn tại, hãy chọn lại một <b>Email</b> khác!"); } else { $user_info = array('full_name' => $full_name, 'mobile_phone' => $mobile_phone, 'home_phone' => $home_phone, 'gender' => $gender == 1 ? 0 : 1, 'yahoo_id' => $yahoo_id, 'skype_id' => $skype_id, 'address' => $address, 'website' => $website); if ($change_pass) { $user_info['password'] = User::encode_password($password); } if ($change_mail) { $user_info['email'] = $email; } DB::update('user', $user_info, "id=" . $this->user['id']); User::getUser($this->user['id'], 0, 1); Url::redirect_current(); } } }
function on_submit() { $user_name = AZLib::trimSpace(Url::get('user_name')); if (preg_match('/[^A-Za-z0-9_.]/', $user_name)) { $this->setFormError('', 'Tài khoản không tồn tại!'); } else { $this->user = DB::select('user', 'user_name="' . $user_name . '"'); if ($this->user) { //Nếu tồn tại user if (isset($_POST['acctive'])) { $active_code = Url::get('active_code'); $this->active_user($this->user, $active_code); } elseif (isset($_POST['re_acctive'])) { //Gửi lại mail kích hoạt $this->reactive_user($this->user); } } else { $this->setFormError('', 'Tài khoản không tồn tại!'); } } }
echo CGlobal::$js_ver; ?> "></script> <script type="text/javascript" src="<?php echo STATIC_URL; ?> javascript/enbac/header.js?v=<?php echo CGlobal::$js_ver; ?> "></script> <script type="text/javascript" src="<?php echo STATIC_URL; ?> javascript/mudim.packed.js?v=0.8-r142"></script> <?php if (Url::get('keywords') && AZLib::trimSpace(AZLib::cleanHtml(Url::get('keywords')))) { echo '<script type="text/javascript" src="' . STATIC_URL . 'javascript/jquery/packed/jquery.highlight-2.js"></script>'; } ?> <script type="text/javascript" src="<?php echo STATIC_URL; ?> javascript/tooltip.js"></script> <script>$eb = jQuery.noConflict(); </script> <?php echo AZNet::$extraHeader; echo AZNet::$extraHeaderJS; if (!DEBUG) { ?>
function get_gallery_entry() { if (User::is_login()) { global $display; if ((User::have_permit(ADMIN_ITEM) || User::is_mod()) && (int) Url::get('user_id', 0) && (int) Url::get('user_id', 0) != User::id()) { $user_id = (int) Url::get('user_id', 0); $display->add('user_id', $user_id); } else { $user_id = User::id(); } $search_value = ' user_id=' . $user_id . ' AND root_id=0 '; //search theo ngay thang nam //$year=(int)Url::get('year',date('Y')); $year = (int) Url::get('year', -1); //$mon= (int)Url::get('month',(int)date('m')); $mon = (int) Url::get('month', -1); $day = (int) Url::get('day', -1); if ($year == 0) { $year = -1; } if ($mon == 0) { $mon = -1; } if ($day == 0) { $day = -1; } $created_time_from = 0; $created_time_to = 0; if ($year != -1) { if ($mon != -1) { if ($day != -1) { $created_time_from = mktime(0, 0, 0, $mon, $day, $year); $created_time_to = mktime(23, 59, 59, $mon, $day, $year); } else { $max_day = 31; if (in_array($mon, array(4, 6, 9, 11))) { $max_day = 30; } elseif ($mon == 2) { $year % 4 ? $max_day = 28 : ($max_day = 29); } $created_time_from = mktime(0, 0, 0, $mon, 1, $year); $created_time_to = mktime(23, 59, 59, $mon, $max_day, $year); } } else { $created_time_from = mktime(0, 0, 0, 1, 1, $year); $created_time_to = mktime(23, 59, 59, 12, 31, $year); } } $y_arr = array(-1 => '-Lọc theo Năm-'); for ($i = 2008; $i <= date('Y'); $i++) { $y_arr[$i] = "---Năm {$i}-"; } $m_arr = array(-1 => '-Lọc theo Tháng-'); for ($i = 1; $i <= 12; $i++) { $m_arr[$i] = "---Tháng {$i}-"; } $d_arr = array(0 => '-Lọc theo Ngày-'); for ($i = 1; $i <= 31; $i++) { $d_arr[$i] = "---Ngày {$i}-"; } $display->add('option_year', AZLib::getOption($y_arr, $year)); $display->add('option_month', AZLib::getOption($m_arr, $mon)); $display->add('option_day', AZLib::getOption($d_arr, $day)); if ($created_time_from) { $search_value .= ' AND time >= ' . $created_time_from; } if ($created_time_to) { $search_value .= ' AND time <= ' . $created_time_to; } $keywords = AZLib::trimSpace(AZLib::getParam('keywords')); $display->add('keywords', $keywords); if ($keywords) { $search_value .= ' AND des LIKE "%' . $keywords . '%" '; } $item_per_page = 20; $sql_count = 'SELECT count(*) AS total_img FROM item_image WHERE ' . $search_value; $total = DB::fetch($sql_count, 'total_img', 0); $paging = ''; $items = array(); $gallery_url = WEB_DIR . 'ajax.php' . Url::build_all(array('page_no')); if ($total) { $limit = ''; $paging = AjaxGalleryPaging($limit, $total, $item_per_page, 5, $gallery_url, 'gallery_content'); $sql = 'SELECT id, des, item_id, title, img_server, img_url, time FROM `item_image` WHERE ' . $search_value . ' ORDER BY id DESC ' . $limit; $re = DB::query($sql); if ($re) { while ($row = mysql_fetch_assoc($re)) { $row['image_url'] = $row['img_url']; $row['img_url'] = AZLib::getImageThumb($row['img_url'], 100, 100, 0, $row['img_server']); $items[$row['id']] = $row; } } } $display->add('items', $items); $display->add('total', $total); $display->add('paging', $paging); $display->output('gallery_ajax_entry', false, 'Personal'); System::halt(); } else { echo "Bạn chưa đăng nhập hoặc đã thoát khỏi hệ thống - Hãy đăng nhập lại!"; } }
static function descriptionText($str) { $meta_desc = AZLib::post_db_parse_html($str); $meta_desc = AZLib::plainText(html_entity_decode($meta_desc, ENT_QUOTES, "UTF-8")); $meta_desc = str_replace('\'', '', $meta_desc); $meta_desc = str_replace('"', '', $meta_desc); return AZLib::delDoubleSpace(AZLib::trimSpace($meta_desc)); }
function search() { global $display; $catid = (int) Url::get('catid', 0); $total = (int) Url::get('total', 0); $page = (int) Url::get('page', 0); $tt = (int) Url::get('tt', 0); $keywords = Url::get('keywords'); require "./includes/sphinxapi.class.php"; AZLib::getCats(); foreach (CGlobal::$allCategories as $value) { if ($value['parent_id'] == 0) { $cat_list[$value['id']] = $value['brief_name']; } } $category = $this->getCategory($keywords); foreach ($category as $row) { $row['brief_name'] = isset($cat_list[$row['level_1_catid']]) && $cat_list[$row['level_1_catid']] ? $cat_list[$row['level_1_catid']] : "Khác"; $listCat[$row['level_1_catid']] = array("level_1_catid" => $row["level_1_catid"], "brief_name" => $row['brief_name'], "count_ad" => $row['@count']); } $catActive = ''; $total_cat = 0; if ($listCat) { $catActive = $listCat[$catid]['brief_name']; $total_cat = count($listCat); } $i = 0; $allrecord = 0; $otherCat = ''; $cat_content = ""; foreach ($listCat as $cat) { $allrecord = $allrecord + $cat['count_ad']; } $display->add("cat_content", $cat_content); $display->add("CatActiveId", $catid); $display->add("catActive", $catActive); $display->add("listCat", $listCat); $display->add("allrecord", $allrecord); $display->add("total_cat", $total_cat); $pager = new Pager(); $limit = SEARCH_LIMIT; $pager->type = "search"; $pager->catid = $catid; $pager->total = $total; $pager->limit = $limit; $pager->page_param = 'page'; $pager->page = $page; $offset = $pager->get_offset(); $limit_from = $pager->limit_from(); $limit_to = $pager->limit_to(); //Sphinx search by Nova $q = $keywords; //$mode = SPH_MATCH_ALL; $mode = SPH_MATCH_EXTENDED2; //Init config $host = SPHINX_SERVER; $port = SPHINX_PORT; $index = 'enbac'; $filtervals = array(); //$ranker = SPH_RANK_PROXIMITY_BM25; $ranker = SPH_RANK_WORDCOUNT; $cl = new SphinxClient(); $cl->SetServer($host, $port); $cl->SetConnectTimeout(1); $cl->SetWeights(array(100, 1)); $cl->SetMatchMode($mode); $cl->SetFilter('level_1_catid', array($catid)); $cl->SetFilter('status', array('1')); $cl->SetFieldWeights(array('user_name' => 10000, 'name' => 1000, 'description' => 1)); //$cl->SetSortMode( SPH_SORT_EXTENDED, 'up_time DESC' ); //$cl->SetSortMode( SPH_SORT_RELEVANCE);//Sort theo kq chính xác nhất //$cl->SetSortMode ( SPH_SORT_EXPR, "@weight + ( user_karma + ln(pageviews) )*0.1"); $cl->SetSortMode(SPH_SORT_EXPR, "@weight"); //Sort theo trọng số $cl->SetLimits($offset, $limit, 10000); $cl->SetRankingMode($ranker); $cl->SetArrayResult(true); $res = $cl->Query($q, $index); if ($res && isset($res["matches"])) { if (is_array($res["matches"])) { foreach ($res["matches"] as $results) { $list_item_id[] = $results['id']; } } $comma_separated = join(",", $list_item_id); } if ($total) { if ($limit_to > $total) { $limit_to = $total; } $comma_separated = join(",", $list_item_id); if ($comma_separated) { //$sql = "SELECT id,name,up_time,price,user_id,user_name, level_1_catid,category_id,description,img_url, img_server FROM item WHERE id IN ($comma_separated) AND status=1 ORDER BY up_time DESC"; $sql = "SELECT id,name,up_time,price,user_id,user_name, level_1_catid,category_id,description,img_url, img_server FROM item WHERE id IN ({$comma_separated}) AND status=1 ORDER BY find_in_set(id,'{$comma_separated}')"; $search_result = DB::query($sql); $pager->total = $total; $paging = $pager->page_link(); } } $item_array = array(); if ($search_result) { AZLib::getCats(); $highlight = ''; if ($keywords) { $highlight = $str_search = str_replace(array('+', '/', '|', '-', '*'), "", $keywords); $highlight = AZLib::trimSpace($highlight); $highlight = str_replace("'", '', $highlight); $highlight = str_replace("'", '', $highlight); $highlight = str_replace(""", '', $highlight); } $highlight1 = ''; if ($highlight) { $arr = explode(' ', $highlight); if ($arr) { $highlight = ""; foreach ($arr as $word) { $highlight = ($highlight ? $highlight . ', ' : '') . "'{$word}'"; $highlight1 = ($highlight1 ? $highlight1 . ',' : '') . $word; } } } while ($item = mysql_fetch_assoc($search_result)) { $item['profile_url'] = WEB_DIR . $item['user_name']; //$item['name'] = AZLib::subString(strip_tags(AZLib::filter_title($item['name'])), 0, 115, true); $item['name_hl'] = AZLib::HighLightKeyword(strip_tags(AZLib::filter_title($item['name'])), $highlight1); $item_time = TIME_NOW - $item['up_time']; //neu nho hon 1h thi tinh ra phut if ($item_time < 3600) { $item['item_time'] = floor($item_time / 60) . " phút trước đây"; } elseif ($item_time < 86400) { $item['item_time'] = floor($item_time / 3600) . " giờ trước đây"; } else { $item['item_time'] = date('\\n\\gà\\y j \\t\\há\\n\\g n', $item['up_time']); } //$item['description'] = String::display_sort_title(AZLib::delDoubleSpace(AZLib::trimSpace(strip_tags(AZLib::post_db_parse_html($item['description'])))), 35); $item['description'] = AZLib::HighLightKeyword(AZLib::delDoubleSpace(AZLib::trimSpace(strip_tags(AZLib::post_db_parse_html(preg_replace('/\\[[0-9]{1,3}\\]/', '', $item['description']))))), $highlight1, 35, "background:yellow;font-size:14px;font-weight:bold;color:blue;"); $ebname = AZLib::safe_title($item['name']); $ebname_tmp = substr(AZLib::safe_title($item['name']), 0, 20); if (isset(CGlobal::$allCategories[$item['category_id']])) { $item['item_url'] = WEB_DIR . AZRewrite::formatUrl('?page=item_detail&id=' . $item['id'] . '&ebname=' . $ebname . '&nice_name=' . CGlobal::$allCategories[$item['category_id']]['nice_name']); $item['item_url_tmp'] = WEB_ROOT . CGlobal::$allCategories[$item['category_id']]['nice_name'] . '/p' . $item['id'] . '/' . $ebname_tmp . '...'; } else { $item['item_url'] = WEB_DIR . AZRewrite::formatUrl('?page=item_detail&id=' . $item['id'] . '&ebname=' . $ebname); $item['item_url_tmp'] = WEB_ROOT . 'p' . $item['id'] . '/' . $ebname_tmp . '...'; } if ($item['img_url']) { $item['img_url'] = AZLib::getImageThumb($item['img_url'], 110, 0, 1, $item['img_server']); } $item['price'] = number_format($item['price'], 0, ',', '.'); $item_array[] = $item; } } $display->add('total_item_cat', $total); $display->add('name_item_cat', $catActive); $display->add('paging', $paging); $display->add('keywords', $keywords); $display->add('items', $item_array); $display->output('sphinx_search_ajax', false, 'sphinx_search'); }
function draw2() { $keywords = AZLib::getParam('keywords'); $total_item = 0; $search_result = false; $items = array(); $paging = ''; $cmd = ''; $cat_search_id = 0; $item_array = array(); $listCat = array(); if ($keywords) { //AZLib::getCats(); require "./includes/sphinxapi.class.php"; foreach (CGlobal::$allCategories as $value) { if ($value['parent_id'] == 0) { $cat_list[$value['id']] = $value['brief_name']; } } $category = $this->getTotalPerCategory($keywords); foreach ($category as $row) { $row['brief_name'] = isset($cat_list[$row['level_1_catid']]) && $cat_list[$row['level_1_catid']] ? $cat_list[$row['level_1_catid']] : "Khác"; $listCat[$row['level_1_catid']] = array("level_1_catid" => $row["level_1_catid"], "brief_name" => $row['brief_name'], "count_ad" => $row['@count']); } $total = 0; $catid = 0; $catActive = ''; $total_cat = 0; if ($listCat) { $first_val = array_slice($listCat, 0, 1); $total = $first_val[0]['count_ad']; $catid = $first_val[0]['level_1_catid']; $catActive = $first_val[0]['brief_name']; $total_cat = count($listCat); } $i = 0; $allrecord = 0; $otherCat = ''; $cat_content = ""; foreach ($listCat as $cat) { if ($i < 3) { $active = $i == 0 ? "class=\"active\"" : ""; $cat_content .= "<li id=\"tab_{$i}\" {$active} onclick=\"javascript:acive_tab_cat(this);\"><a href=\"javascript:void(0);\" onclick=\"javascript:search_cat({$cat['level_1_catid']},{$cat['count_ad']},1,0);\"><span id=\"kby_{$cat['level_1_catid']}\">" . $cat['brief_name'] . " <font style=\"color: #5a7e92;font-weight: normal;\">(" . $cat['count_ad'] . ")</font></span></a></li>"; } else { $otherCat .= "<div class=\"other\"><a href=\"javascript:void(0);\" onclick=\"javascript:search_cat({$cat['level_1_catid']},{$cat['count_ad']},1,0);acive_tab_cat(this);\" id=\"tab_{$i}\"><span id=\"kby_{$cat['level_1_catid']}\">" . $cat['brief_name'] . " <font style=\"color: #5a7e92;font-weight: normal;\">(" . $cat['count_ad'] . ")</font></span></a></div>"; } $i++; $allrecord = $allrecord + $cat['count_ad']; } $display->add("cat_content", $cat_content); $display->add("CatActiveId", $catid); $display->add("catActive", $catActive); $display->add("listCat", $listCat); $display->add("allrecord", $allrecord); $display->add("otherCat", str_replace(array(chr(13), chr(10)), "", $otherCat)); $display->add("total_cat", $total_cat); //Init for sphinx search paging $pager = new Pager(); //config $limit = SEARCH_LIMIT; $pager->type = "search"; $pager->catid = $catid; $pager->total = $total; $pager->limit = $limit; $pager->page_param = 'page'; $pager->page = 1; $offset = $pager->get_offset(); $limit_from = $pager->limit_from(); $limit_to = $pager->limit_to(); //Sphinx search by Nova $q = $keywords; $mode = SPH_MATCH_EXTENDED2; //Init config $host = SPHINX_SERVER; $port = SPHINX_PORT; //$index = SPHINX_INDEX; $index = "enbac delta"; $filtervals = array(); $ranker = SPH_RANK_WORDCOUNT; $cl = new SphinxClient(); $cl->SetServer($host, $port); $cl->SetConnectTimeout(1); $cl->SetWeights(array(100, 1)); $cl->SetMatchMode($mode); //filter if ($catid) { $cl->SetFilter('level_1_catid', array($catid)); } $cl->SetFilter('status', array('1')); $cl->SetFieldWeights(array('user_name' => 10000, 'name' => 1000, 'description' => 1)); //$cl->SetSortMode( SPH_SORT_EXTENDED, 'up_time DESC' ); //$cl->SetSortMode( SPH_SORT_RELEVANCE);//Sort theo kq chính xác nhất //$cl->SetSortMode ( SPH_SORT_EXPR, "@weight + ( user_karma + ln(pageviews) )*0.1"); $cl->SetSortMode(SPH_SORT_EXPR, "@weight"); //Sort theo trọng số //SPH_RANK_WORDCOUNT //SPH_MATCH_EXTENDED2 //end filter $cl->SetLimits($offset, $limit, 10000); $cl->SetRankingMode($ranker); $cl->SetArrayResult(true); $res = $cl->Query($q, $index); /*echo '<pre>'; print_r($res["matches"]);*/ if ($res && isset($res["matches"])) { if (is_array($res["matches"])) { foreach ($res["matches"] as $results) { $list_item_id[] = $results['id']; } } $comma_separated = join(",", $list_item_id); } if ($total) { if ($limit_to > $total) { $limit_to = $total; } $comma_separated = join(",", $list_item_id); if ($comma_separated) { //$sql = "SELECT id,name,up_time,price,user_id,user_name, level_1_catid,category_id,description,img_url, img_server FROM item WHERE id IN($comma_separated) AND status=1 ORDER BY up_time DESC"; //$sql = "SELECT id,name,up_time,price,user_id,user_name, level_1_catid,category_id,description,img_url, img_server FROM item WHERE id IN($comma_separated) AND status=1 AND state=0 ORDER BY find_in_set(id,'$comma_separated')"; $sql = "SELECT id,name,up_time,price,user_id,user_name, level_1_catid,category_id,description,img_url, img_server FROM item WHERE id IN({$comma_separated}) AND status=1 ORDER BY find_in_set(id,'{$comma_separated}')"; $search_result = DB::query($sql); $pager->total = $total; $paging = $pager->page_link(); } } } $highlight = ''; if ($keywords) { $highlight = $str_search = str_replace(array('+', '/', '|', '-', '*'), "", $keywords); $highlight = AZLib::trimSpace($highlight); $highlight = str_replace("'", '', $highlight); $highlight = str_replace("'", '', $highlight); $highlight = str_replace(""", '', $highlight); } $highlight1 = ''; if ($highlight) { $arr = explode(' ', $highlight); if ($arr) { $highlight = ""; foreach ($arr as $word) { $highlight = ($highlight ? $highlight . ', ' : '') . "'{$word}'"; $highlight1 = ($highlight1 ? $highlight1 . ',' : '') . $word; } } } if ($keywords && $search_result) { while ($item = mysql_fetch_assoc($search_result)) { $item['profile_url'] = WEB_DIR . $item['user_name']; $item['name_hl'] = AZLib::HighLightKeyword(strip_tags(AZLib::filter_title($item['name'])), $highlight1); $item_time = TIME_NOW - $item['up_time']; //neu nho hon 1h thi tinh ra phut if ($item_time < 3600) { $item['item_time'] = floor($item_time / 60) . " phút trước đây"; } elseif ($item_time < 86400) { $item['item_time'] = floor($item_time / 3600) . " giờ trước đây"; } else { $item['item_time'] = date('\\n\\gà\\y j \\t\\há\\n\\g n', $item['up_time']); } $item['description'] = AZLib::HighLightKeyword(AZLib::delDoubleSpace(AZLib::trimSpace(strip_tags(AZLib::post_db_parse_html(preg_replace('/\\[[0-9]{1,3}\\]/', '', $item['description']))))), $highlight1, 35, "background:yellow;font-size:14px;font-weight:bold;color:blue;"); $ebname = AZLib::safe_title($item['name']); $ebname_tmp = substr(AZLib::safe_title($item['name']), 0, 20); if (isset(CGlobal::$allCategories[$item['category_id']])) { $item['item_url'] = WEB_DIR . AZRewrite::formatUrl('?page=item_detail&id=' . $item['id'] . '&ebname=' . $ebname . '&nice_name=' . CGlobal::$allCategories[$item['category_id']]['nice_name']); $item['item_url_tmp'] = WEB_ROOT . CGlobal::$allCategories[$item['category_id']]['nice_name'] . '/p' . $item['id'] . '/' . $ebname_tmp . '...'; } else { $item['item_url'] = WEB_DIR . AZRewrite::formatUrl('?page=item_detail&id=' . $item['id'] . '&ebname=' . $ebname); $item['item_url_tmp'] = WEB_ROOT . 'p' . $item['id'] . '/' . $ebname_tmp . '...'; } if ($item['img_url']) { $item['img_url'] = AZLib::getImageThumb($item['img_url'], 110, 0, 1, $item['img_server']); } $item['price'] = number_format($item['price'], 0, ',', '.'); $item_array[] = $item; } } global $start_rb; $mtime = microtime(); $mtime = explode(" ", $mtime); $mtime = $mtime[1] + $mtime[0]; $end_rb = $mtime; $search_time = round($end_rb - $start_rb, 3); $display->add('limit_from', $limit_from); $display->add('limit_to', $limit_to); $display->add('search_time', $search_time); $display->add('keywords', $keywords); $display->add('base_url', WEB_ROOT); $display->add('highlight', $highlight); $display->add('total_item_cat', $total); $display->add('name_item_cat', $catActive); $display->add('block_id', Module::$block_id); $display->add('paging', $paging); $display->add('items', $item_array); $display->output('sphinx_search'); }
function filter_link($link, $text) { if ($text = AZLib::trimSpace(AZLib::plainText($text))) { $text = AZLib::strippedLink($text); if (strpos($link, 'http://enbac.com') === 0 || strpos($link, 'http://www.enbac.com') === 0 || strpos($link, 'enbac.com') === 0 || strpos($link, 'http://') === false) { return "<a href=\"{$link}\" target=\"_blank\">{$text}</a>"; } else { if (strpos($link, 'http://blog.enbac.com') === 0 || strpos($link, 'blog.enbac.com') === 0 || strpos($link, 'http://') === false) { return "<a href=\"{$link}\" target=\"_blank\">{$text}</a>"; } else { if (strpos($link, 'http://help.enbac.com') === 0 || strpos($link, 'help.enbac.com') === 0 || strpos($link, 'http://') === false) { return "<a href=\"{$link}\" target=\"_blank\">{$text}</a>"; } } } return "<a href=\"#\" rel=\"nofollow\" target=\"_blank\">...</a>"; } return ''; }
static function filter_tag_search($string_input, $show_tag_search = false, $html_entity_decode = false) { $set_tag_search = ''; $arr_tag_search = self::get_tag_search(Item::$item['category_id'], Item::$item['level_1_catid']); foreach ($arr_tag_search as $value_tagsearch) { $set_tag_search .= ($set_tag_search ? ', ' : '') . $value_tagsearch["keywords"]; } $url_root = WEB_ROOT . 'search?keywords='; if (!$string_input || !$set_tag_search) { return false; } if ($html_entity_decode) { $html_entity_decode = html_entity_decode($html_entity_decode, ENT_QUOTES, "UTF-8"); } $set_tag_search = trim(mb_strtolower($set_tag_search, mb_detect_encoding($set_tag_search))); $string_input = trim(strip_tags(mb_strtolower($string_input, mb_detect_encoding($string_input)))); //explode to array $tag_search_list = explode(',', $set_tag_search); $tag_search_list = array_map('trim', $tag_search_list); $filtro = str_replace('||', '|', implode('|', $tag_search_list)); $filtro = AZLib::delDoubleSpace(AZLib::trimSpace($filtro)); $filtro = preg_replace("/\\/|\\*/is", "", $filtro); //loai ky tu: / * $string_input = AZLib::delDoubleSpace(AZLib::trimSpace($string_input)); if ($show_tag_search) { preg_match_all("/({$filtro})/is", $string_input, $matches); $set_tag_search = ""; $arr_temp = array(); foreach ($matches[0] as $value) { if (!in_array($value, $arr_temp)) { $set_tag_search .= ($set_tag_search ? ', ' : '') . '<a target="_blank" href="' . $url_root . urlencode($value) . '">' . $value . '</a>'; $arr_temp[] = $value; } } return $set_tag_search; } else { if (preg_match("/({$filtro})/is", $string_input)) { return true; } } return false; }
function on_submit() { if (User::checkLock4Ever(1)) { Url::redirect_current(); } //check bảo mật $just_registed_s = 0; $just_registed_c = 0; if (isset($_SESSION['just_registed'])) { $just_registed_s = $_SESSION['just_registed']; } if (isset($_COOKIE['just_registed'])) { $just_registed_c = $_COOKIE['just_registed']; } if ($just_registed_s > TIME_NOW - 120 || $just_registed_c > TIME_NOW - 120 || !REG_ON) { Url::redirect_current(); } //END check bảo mật // check de ban IP $ip = AZLib::ip(); $arr_badwords = AZLib::checkBadWord($ip, true); if ($arr_badwords["bad"] != "" && $arr_badwords["bad_key"] != "") { $this->setFormError('ban_ip', "Có lỗi xẩy ra"); } // end check de ban IP $full_name = Url::get('full_name'); $email = Url::get('email'); $user_name = Url::get('register_user_name'); $mobile_phone = AZLib::trimSpace(Url::get('mobile_phone')); $password = AZLib::trimSpace(Url::get('register_password')); $confirm_password = AZLib::trimSpace(Url::get('confirm_password')); $this->checkFormInput('Tên đầy đủ', 'full_name', $full_name, 'str', false, '', 0, 50); $this->checkFormInput('Email', 'email', $email, 'email', true, '', 6, 50); $this->checkFormInput('Tên truy cập', 'user_name', $user_name, 'uname', true, '', 4, 50); $this->checkFormInput('Điện thoại di động', 'mobile_phone', $mobile_phone, 'str', false, '', 0, 50); $this->checkFormInput('Mật khẩu truy cập', 'register_password', $password, 'str', true, '', 6, 50); $this->checkFormInput('Nhập lại mật khẩu', 'confirm_password', $confirm_password, 'str', true, '', 6, 50); if (!$this->errNum) { if ($password != $confirm_password) { $this->setFormError('captcha_register', "Nhập lại Mật khẩu truy cập không khớp!"); return; } } $captcha_register = Url::get('captcha_register'); if ($mobile_phone && !AZLib::is_mobile($mobile_phone)) { $mobile_phone = ""; } if ($captcha_register == '') { $this->setFormError('captcha_register', "Bạn chưa nhập <b>Mã bảo mật</b>!"); } else { if (!isset($_SESSION["enbac_validate"]) || $captcha_register != $_SESSION["enbac_validate"]) { $this->setFormError('captcha_register', "<b>Mã bảo mật</b> không chính xác!"); } } if ((int) Url::get('confirm_register') != 1) { $this->setFormError('confirm_register', "Bạn phải đọc và đồng ý với những <a target=\"_blank\" href=\"http://help.enbac.com/content/4/5/en/Quy-che-thanh-vien.html\" >điều khoản của Enbac.com</a>!"); } if (!$this->errNum) { if (DB::exists('SELECT id FROM `user` WHERE `email`="' . $email . '"')) { $this->setFormError('email', "<b>Email</b> bạn chọn đã tồn tại, hãy chọn lại một <b>Email</b> khác!"); } elseif (DB::exists('SELECT id FROM `user` WHERE `user_name`="' . $user_name . '"')) { $this->setFormError('email', "<b>Tên truy cập</b> bạn chọn đã tồn tại, hãy chọn lại một <b>Tên truy cập</b> khác!"); } else { $user_info = array('user_name' => $user_name, 'email' => $email, 'password' => User::encode_password($password), 'full_name' => $full_name, 'mobile_phone' => $mobile_phone, 'create_time' => TIME_NOW, 'is_active' => (int) (bool) USER_ACTIVE_ON, 'reg_ip' => AZLib::ip()); $id = DB::insert('user', $user_info); if ($id) { $_SESSION['just_registed'] = TIME_NOW; AZLib::my_setcookie('just_registed', TIME_NOW); if (USER_ACTIVE_ON && $user_info['is_active'] == 1) { global $display; $active = DB::select('user_active', 'user_id=' . $id); $active_code = md5(TIME_NOW . $user_info['password']); if ($active) { $active = array('id' => $active['id'], 'user_id' => $id, 'active_code' => $active_code, 'time' => TIME_NOW); } else { $active = array('user_id' => $id, 'active_code' => $active_code, 'time' => TIME_NOW); } DB::insert('user_active', $active, true); $display->add('eb_url', WEB_ROOT); $display->add('user_id', $id); $display->add('user_name', $user_info['user_name']); $display->add('active_code', $active_code); $display->add('WEB_NAME', WEB_NAME); $display->add('MAIL_FOOTER', MAIL_FOOTER); $content_email = $display->output('send_active_mail', 1, 'RegisterSuccess'); //Send email here; if (System::sendEBEmail($user_info['email'], 'Kích hoạt tài khoản!', $content_email)) { //$this->setFormSucces('','<b>Chúc mừng bạn đã đăng ký tài khoản thành công!</b><br /><br />Mã kích hoạt đã được gửi đi tới E-mail: "'.$user_info['email'].'"<br />Bạn hãy check lại Email để kích hoạt tài khoản của mình!'); Url::redirect('reg_success', array('cmd' => 'notify')); } else { $this->setFormError('', '<b>Chúc mừng bạn đã đăng ký tài khoản thành công!</b><br /><br />Tuy nhiên hệ thống chưa gửi được Mã kích hoạt tới E-mail: "' . $user_info['email'] . '"!<br />Bạn có thể <a href="' . Url::build('reg_success', array('cmd' => 'active')) . '">click vào đây</a> để hệ thống gửi lại mã kích hoạt vào Email của mình!'); } $this->show_form = false; } else { User::Login($id); Url::redirect('reg_success'); } } else { $this->setFormError('', "Chưa đăng ký được, mời bạn thử lại!"); } } } }
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', 0)); $price_out = Url::cdouble(Url::get('price_out', 0)); $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) { //Nếu chọn danh mục cấp 2 $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]; //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 if (isset(CGlobal::$subCategories[$category_id]) && CGlobal::$subCategories[$category_id] && $item_category['parent_id'] == 0 || $item_category['parent_id'] != $first_combo) { $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!'); } $this->checkFormInput('Tên sản phẩm', 'name', $name, 'str', true, '', 5, 255); $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ị $have_image_up = false; $form_img_server = Url::get('avatar_img_server', 0); $this->img_url = Url::get('avatar_img_url', ''); foreach ($this->item_images as $page => $page_images) { //trang foreach ($page_images as $image) { if ($image['img_new_id']) { $have_image_up = true; break; } } } if (!$this->errNum) { $item_array = array('category_id' => $category_id, 'level_1_catid' => $level_1_catid, 'level_2_catid' => $level_2_catid, 'currency_id' => $currency_id, 'quantity' => $quantity, 'item_order' => $item_order, 'made_in' => $made_in, 'warranty' => $warranty, 'price' => $price, 'price_out' => $price_out, 'sku' => $sku, 'name' => $name, 'offer' => $offer, 'list_brief' => $list_brief, 'brief' => $brief, 'description' => $item_description, 'status' => $status, 'created_time' => TIME_NOW, 'user_id' => User::id(), 'user_name' => User::user_name(), 'modify_time' => TIME_NOW, 'modify_user_name' => User::user_name(), 'img_server' => $form_img_server, 'have_image' => (int) (bool) $this->img_url, 'img_url' => $this->img_url); $id = DB::insert('item', $item_array); if (!$id) { $this->setFormError('', "Không đăng được Sản phẩm! Mời bạn thử lại!"); } $image_err = false; $i_server = 0; $img_url = ''; $item_images = array(); $item_insert_temp_images = array(); $item_insert_images = array(); $item_update_images = array(); $img_ids = ''; foreach ($this->item_images as $page => $page_images) { //trang foreach ($page_images as $image) { if ($image['img_new_id']) { $img = array(); $img_ids .= ($img_ids ? ',' : '') . $image['img_new_id']; $img['item_id'] = $id; $img['title'] = $image['title'] && $image['title'] != 'Ghi chú ảnh' && !AZLib::checkBadWord($image['title']) ? addslashes($image['title']) : ''; $img['position'] = $image['stt']; $img['img_server'] = $image['img_server']; $img['img_url'] = ''; $img['root_id'] = 0; $img['time'] = TIME_NOW; $img['user_id'] = User::id(); $img['user_name'] = User::user_name(); 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í } } } } if ($img_ids) { $re = DB::query('SELECT id, item_id, user_id, img_server, img_url,root_id, time FROM item_image WHERE id IN(' . $img_ids . ')'); if ($re) { $pos = 0; while ($img = mysql_fetch_assoc($re)) { 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_server'] = $img['img_server']; $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 ($img_url == '' || $pos == 0 || $item_images[$img['id']]['position'] <= $pos) { $pos = $item_images[$img['id']]['position']; $i_server = $img['img_server']; $img_url = $img['img_url']; } } } } 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; } } } #Filters ############################################################################## $item_array = array('filter_search' => $filter_search, '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; } $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_insert_images || $item_update_images) { //tuannk 2010.07.26 $item_array['have_image'] = 1; } DB::update('item', $item_array, 'id=' . $id); if (Url::get('ref')) { Url::redirect("manage_item"); } else { Url::redirect("item_detail", array("id" => $id)); } } }
function draw() { $this->beginForm(); global $display; AZLib::getCats(); $acc_groups = CGlobal::$group; $user_permits = array(); $user_cats = array(); $all_users = array(); $allist_users = array(); $gids = ''; foreach ($acc_groups as $group) { $acc_groups[$group['id']]['users'] = array(); $acc_groups[$group['id']]['pids'] = array(); $acc_groups[$group['id']]['pid_str'] = ''; if (!in_array($group['id'], array(1, 9))) { $gids .= ($gids ? ',' : '') . $group['id']; } } if ($gids) { // $sql = "SELECT pids,ref_id FROM user_permit WHERE ref_id IN(".$gids.") AND type=0";//lấy quyền của nhóm $sql = "SELECT type, ref_id, pids, cids FROM user_permit"; //lấy quyền của nhóm $result = DB::query($sql); if ($result) { while ($row = mysql_fetch_assoc($result)) { if ($row['type'] == 0) { //group $acc_groups[$row['ref_id']]['pid_str'] .= ($acc_groups[$row['ref_id']]['pid_str'] ? '|' : '') . $row['pids']; $pids = explode('|', $row['pids']); $acc_groups[$row['ref_id']]['pids'] = array(); foreach ($pids as $pid) { $acc_groups[$row['ref_id']]['pids'][$pid] = CGlobal::$permit[$pid]; } } else { //user $user_permits[$row['ref_id']] = $row['pids']; $user_cats[$row['ref_id']] = $row['cids']; } } } } $sql = 'SELECT id, user_name, full_name, gids FROM user AS a WHERE a.gids!="0"'; $result = DB::query($sql); if ($result) { while ($row = mysql_fetch_assoc($result)) { $row['full_name'] = AZLib::trimSpace($row['full_name']); $all_users[$row['id']] = $row; $row['pid_str'] = isset($user_permits[$row['id']]) ? $user_permits[$row['id']] : ''; $row['cid_str'] = isset($user_cats[$row['id']]) ? $user_cats[$row['id']] : ''; $groups = explode('|', $row['gids']); foreach ($groups as $gid) { if (isset($acc_groups[$gid])) { if (!User::is_root() && $gid == 9) { $row['del_enable'] = 0; } else { $row['del_enable'] = 1; } $acc_groups[$gid]['users'][] = $row; } } $pid_str = isset($user_permits[$row['id']]) ? $user_permits[$row['id']] : ''; $cid_str = isset($user_cats[$row['id']]) ? $user_cats[$row['id']] : ''; $pid_arr = explode('|', $pid_str); $cid_arr = explode(',', $cid_str); $row['pids'] = array(); $row['cids'] = array(); if ($pid_arr) { foreach ($pid_arr as $pid) { if (isset(CGlobal::$permit[$pid])) { $row['pids'][$pid] = CGlobal::$permit[$pid]; } } } if ($pid_arr) { foreach ($cid_arr as $cid) { if (isset(CGlobal::$allCategories[$cid])) { $row['cids'][$cid] = CGlobal::$allCategories[$cid]; } } } if ($row['pids'] || $row['cids']) { $allist_users[$row['id']] = $row; } } } $display->add('acc_groups', $acc_groups); $display->add('all_users', json_encode($all_users)); $display->add('allist_users', $allist_users); $all_groups = CGlobal::$group; if (!User::is_root()) { unset($all_groups[9]); } $display->add('all_groups', json_encode($all_groups)); $display->add('all_permits', json_encode(CGlobal::$permit)); $display->output('ListAdmin'); $this->endForm(); }
function fn_processed_bad_content() { if (!User::have_permit(ADMIN_USER)) { echo 'no_perm'; exit; } $id = (int) Url::get('id', 0); $status = (int) Url::get('status', 0); $note = AZLib::trimSpace(Url::get('note', '')); if ($id > 0 && ($status == 0 || $status == 1)) { if ($status == 1) { $item = DB::select('bad_content', 'id = ' . $id); $receiver_user = DB::select('user', 'id = ' . $item["user_id"]); $title_pm = 'Thông báo từ EnBac'; $content_pm = 'Cảm ơn bạn đã than phiền một tin với nội dung "' . $item["reason"] . '". Chúng tôi đã xử lý: ' . $note . ' Rất mong sự đóng góp của bạn để én bạc ngày càng phát triển hơn. BQT én bạc! Vui lòng không trả lời tin nhắn này!'; AZLib::Send_pm(User::id(), User::user_name(), $receiver_user, $title_pm, $content_pm, true); } if (DB::query("UPDATE bad_content SET status={$status}, admin_id=" . User::id() . ", admin_name='" . User::user_name() . "', note='" . $note . "' WHERE id={$id}")) { echo "success"; exit; } else { echo "unsuccess"; exit; } } }
function on_submit() { $full_name = Url::get('full_name'); $email = Url::get('email'); $user_name = Url::get('register_user_name'); $mobile_phone = AZLib::trimSpace(Url::get('mobile_phone')); $home_phone = AZLib::trimSpace(Url::get('home_phone')); $password = AZLib::trimSpace(Url::get('register_password')); $confirm_password = AZLib::trimSpace(Url::get('confirm_password')); $gender = (int) Url::get('gender'); $yahoo_id = AZLib::trimSpace(Url::get('yahoo_id')); $skype_id = AZLib::trimSpace(Url::get('skype_id')); $address = AZLib::trimSpace(Url::get('address')); $website = AZLib::trimSpace(Url::get('website')); $this->checkFormInput('Tên đầy đủ', 'full_name', $full_name, 'str', false, '', 0, 50); $this->checkFormInput('Email', 'email', $email, 'email', true, '', 6, 50); $this->checkFormInput('Tên truy cập', 'user_name', $user_name, 'uname', true, '', 4, 50); $this->checkFormInput('Điện thoại di động', 'mobile_phone', $mobile_phone, 'str', false, '', 0, 50); $this->checkFormInput('Điện thoại bàn', 'home_phone', $home_phone, 'str', false, '', 0, 50); $this->checkFormInput('Mật khẩu truy cập', 'register_password', $password, 'str', true, '', 6, 50); $this->checkFormInput('Nhập lại mật khẩu', 'confirm_password', $confirm_password, 'str', true, '', 6, 50); if ($password != $confirm_password) { $this->setFormError('confirm_password', "Nhập lại Mật khẩu truy cập không khớp!"); return; } if ($mobile_phone && !AZLib::is_mobile($mobile_phone)) { $mobile_phone = ""; } if (!$this->errNum) { if (DB::exists('SELECT id FROM `user` WHERE `email`="' . $email . '"')) { $this->setFormError('email', "<b>Email</b> bạn chọn đã tồn tại, hãy chọn lại một <b>Email</b> khác!"); } elseif (DB::exists('SELECT id FROM `user` WHERE `user_name`="' . $user_name . '"')) { $this->setFormError('email', "<b>Tên truy cập</b> bạn chọn đã tồn tại, hãy chọn lại một <b>Tên truy cập</b> khác!"); } else { $user_info = array('user_name' => $user_name, 'email' => $email, 'password' => User::encode_password($password), 'full_name' => $full_name, 'mobile_phone' => $mobile_phone, 'home_phone' => $home_phone, 'create_time' => TIME_NOW, 'gender' => $gender == 1 ? 0 : 1, 'yahoo_id' => $yahoo_id, 'skype_id' => $skype_id, 'address' => $address, 'website' => $website, 'is_active' => (int) (bool) USER_ACTIVE_ON, 'reg_ip' => AZLib::ip()); $id = DB::insert('user', $user_info); if ($id) { if (USER_ACTIVE_ON && $user_info['is_active'] == 1) { global $display; $active = DB::select('user_active', 'user_id=' . $id); $active_code = md5(TIME_NOW . $user_info['password']); if ($active) { $active = array('id' => $active['id'], 'user_id' => $id, 'active_code' => $active_code, 'time' => TIME_NOW); } else { $active = array('user_id' => $id, 'active_code' => $active_code, 'time' => TIME_NOW); } DB::insert('user_active', $active, true); $display->add('eb_url', WEB_ROOT); $display->add('user_id', $id); $display->add('user_name', $user_info['user_name']); $display->add('active_code', $active_code); $content_email = $display->output('send_active_mail', 1, 'RegisterSuccess'); //Send email here; if (System::sendEBEmail($user_info['email'], 'Kích hoạt tài khoản!', $content_email)) { Url::redirect_current(); } else { $this->setFormError('', '<b>Tạo mới tài khoản thành công!</b><br /><br />Tuy nhiên hệ thống chưa gửi được Mã kích hoạt tới E-mail: "' . $user_info['email'] . '"!'); } $this->show_form = false; } else { Url::redirect_current(); } } else { $this->setFormError('', "Chưa đăng ký được, mời bạn thử lại!"); } } } }
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('"'), 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('"'), 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)); } } }