if (!empty($image_order)) { $image_order .= ','; } $image_order .= $_POST['image_order'][$i]; } } } elseif ($image_order_choice == 'rank') { $image_order = 'rank ASC'; } $query = ' UPDATE ' . CATEGORIES_TABLE . ' SET image_order = ' . (isset($image_order) ? '\'' . $image_order . '\'' : 'NULL') . ' WHERE id=' . $page['category_id']; pwg_query($query); if (isset($_POST['image_order_subcats'])) { $cat_info = get_cat_info($page['category_id']); $query = ' UPDATE ' . CATEGORIES_TABLE . ' SET image_order = ' . (isset($image_order) ? '\'' . $image_order . '\'' : 'NULL') . ' WHERE uppercats LIKE \'' . $cat_info['uppercats'] . ',%\''; pwg_query($query); } $page['infos'][] = l10n('Your configuration settings are saved'); } // +-----------------------------------------------------------------------+ // | template init | // +-----------------------------------------------------------------------+ $template->set_filenames(array('element_set_ranks' => 'element_set_ranks.tpl')); $base_url = get_root_url() . 'admin.php'; $query = ' SELECT *
require_once AT_INCLUDE_PATH . '../mods/_standard/links/lib/links.inc.php'; $linkIndexHeader = sprintf('Location: %smods/_standard/links/tools/index.php', AT_BASE_HREF); if (!manage_links()) { $msg->addError('ACCESS_DENIED'); header('Location: ' . AT_BASE_HREF . 'mods/_standard/links/index.php'); exit; } $lid = explode('-', $_REQUEST['lid']); $link_id = intval($lid[0]); if (isset($_POST['submit_no'])) { $msg->addFeedback('CANCELLED'); header($linkIndexHeader); exit; } else { if (isset($_POST['submit_yes'])) { $row = get_cat_info(intval($_POST['cat_id'])); if (!links_authenticate($row['owner_type'], $row['owner_id'])) { $msg->addError('ACCESS_DENIED'); header($linkIndexHeader); exit; } queryDB('DELETE FROM %slinks WHERE link_id=%d', array(TABLE_PREFIX, $_POST[link_id])); $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY'); header($linkIndexHeader); exit; } } $_section[0][0] = _AT('delete_link'); require_once AT_INCLUDE_PATH . 'header.inc.php'; $row = queryDB('SELECT LinkName, cat_id FROM %slinks WHERE link_id=%d', array(TABLE_PREFIX, $link_id), true); if (empty($row)) {
$child_list = get_category_child($cat_id, ' AND is_new = 1 '); $on_top_goods = get_on_top_goods($cat_id, 10); $smarty->assign('cat_child', $child_list); $smarty->assign('on_top_goods', $on_top_goods); $smarty->assign('cat_info', $cat); $smarty->assign('group_buy_goods', index_get_group_buy()); // 团购商品 } else { $sql = 'SELECT parent_id FROM ' . $GLOBALS['ecs']->table('category') . ' WHERE cat_id = ' . $cat_id; $parent_id = $GLOBALS['db']->getOne($sql); while ($parent_id != 0) { $parent_id_org = $parent_id; $sql = 'SELECT parent_id FROM ' . $GLOBALS['ecs']->table('category') . ' WHERE cat_id = ' . $parent_id; $parent_id = $GLOBALS['db']->getOne($sql); } $cat = get_cat_info($parent_id_org); // 获得分类的相关信息 $smarty->assign('cat_info', $cat); $smarty->assign('category_org', $parent_id_org); // 分类树 } $smarty->assign('script_name', 'category'); assign_pager('category', $cat_id, $count, $size, $sort, $order, $page, '', $brand, $price_min, $price_max, $display, $filter_attr_str); // 分页 assign_dynamic($dwt_name); // 动态内容 } $smarty->display($dwt_name . '.dwt', $cache_id); /*------------------------------------------------------ */ //-- PRIVATE FUNCTION /*------------------------------------------------------ */
$data = array('id' => $_GET['cat_id'], 'name' => @$_POST['name'], 'comment' => $conf['allow_html_descriptions'] ? @$_POST['comment'] : strip_tags(@$_POST['comment'])); if ($conf['activate_comments']) { $data['commentable'] = isset($_POST['commentable']) ? $_POST['commentable'] : 'false'; } single_update(CATEGORIES_TABLE, $data, array('id' => $data['id'])); if (isset($_POST['apply_commentable_on_sub'])) { $subcats = get_subcat_ids(array('id' => $data['id'])); $query = ' UPDATE ' . CATEGORIES_TABLE . ' SET commentable = \'' . $data['commentable'] . '\' WHERE id IN (' . implode(',', $subcats) . ') ;'; pwg_query($query); } // retrieve cat infos before continuing (following updates are expensive) $cat_info = get_cat_info($_GET['cat_id']); if ($_POST['visible'] == 'true_sub') { set_cat_visible(array($_GET['cat_id']), true, true); } elseif ($cat_info['visible'] != get_boolean($_POST['visible'])) { set_cat_visible(array($_GET['cat_id']), $_POST['visible']); } // in case the use moves his album to the gallery root, we force // $_POST['parent'] from 0 to null to be compared with // $cat_info['id_uppercat'] if (empty($_POST['parent'])) { $_POST['parent'] = null; } // only move virtual albums if (empty($cat_info['dir']) and $cat_info['id_uppercat'] != $_POST['parent']) { move_categories(array($_GET['cat_id']), $_POST['parent']); }
// where to redirect the user now? // // 1. if a category is available in the URL, use it // 2. else use the first reachable linked category // 3. redirect to gallery root if (isset($_GET['cat_id']) and !empty($_GET['cat_id'])) { redirect(make_index_url(array('category' => get_cat_info($_GET['cat_id'])))); } $query = ' SELECT category_id FROM ' . IMAGE_CATEGORY_TABLE . ' WHERE image_id = ' . $_GET['image_id'] . ' ;'; $authorizeds = array_diff(array_from_query($query, 'category_id'), explode(',', calculate_permissions($user['id'], $user['status']))); foreach ($authorizeds as $category_id) { redirect(make_index_url(array('category' => get_cat_info($category_id)))); } redirect(make_index_url()); } // +-----------------------------------------------------------------------+ // | synchronize metadata | // +-----------------------------------------------------------------------+ if (isset($_GET['sync_metadata'])) { sync_metadata(array(intval($_GET['image_id']))); $page['infos'][] = l10n('Metadata synchronized from file'); } //--------------------------------------------------------- update informations if (isset($_POST['submit'])) { $data = array(); $data['id'] = $_GET['image_id']; $data['name'] = $_POST['name'];
$link[1]['text'] = $_LANG['back_list']; $link[1]['href'] = 'category.php?act=list'; sys_msg($_LANG['catadd_succed'], 0, $link); } } /*------------------------------------------------------ */ //-- 编辑商品分类信息 /*------------------------------------------------------ */ if ($_REQUEST['act'] == 'edit') { admin_priv('cat_manage'); // 权限检查 $cat_id = intval($_REQUEST['cat_id']); $cat_info = get_cat_info($cat_id); // 查询分类信息数据 $attr_list = get_attr_list(); $filter_attr_list = array(); if ($cat_info['filter_attr']) { $filter_attr = explode(",", $cat_info['filter_attr']); //把多个筛选属性放到数组中 foreach ($filter_attr AS $k => $v) { $attr_cat_id = $db->getOne("SELECT cat_id FROM " . $ecs->table('attribute') . " WHERE attr_id = '" . intval($v) . "'"); $filter_attr_list[$k]['goods_type_list'] = goods_type_list($attr_cat_id); //取得每个属性的商品类型 $filter_attr_list[$k]['filter_attr'] = $v; $attr_option = array(); foreach ($attr_list[$attr_cat_id] as $val)
if (!links_authenticate($owner_type, $owner_id)) { $msg->addError('ACCESS_DENIED'); header('Location: ' . AT_BASE_HREF . 'mods/_standard/links/tools/categories.php'); exit; } //check if there are sub cats within this cat, or links $result = queryDB('SELECT C.cat_id, L.link_id FROM %slinks_categories C, %slinks L WHERE C.parent_id=%d OR L.cat_id=%d', array(TABLE_PREFIX, TABLE_PREFIX, $cat_id, $cat_id)); if (empty($result)) { queryDB("DELETE FROM %slinks_categories WHERE owner_id=%d AND owner_type=%s AND cat_id=%d", array(TABLE_PREFIX, $owner_id, $owner_type, $cat_id)); $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY'); } else { $msg->addError('LINK_CAT_NOT_EMPTY'); } header('Location: categories.php'); exit; } } require AT_INCLUDE_PATH . 'header.inc.php'; $row = get_cat_info($cat_id); if (empty($row)) { $msg->printErrors('ITEM_NOT_FOUND'); } else { $hidden_vars['cat_name'] = $row['name']; $hidden_vars['cat_id'] = $row['cat_id']; $hidden_vars['owner_type'] = $row['owner_type']; $hidden_vars['owner_id'] = $row['owner_id']; $confirm = array('DELETE_CATEGORY', AT_print($row['name'], 'links_categories.name')); $msg->addConfirm($confirm, $hidden_vars); $msg->printConfirm(); } require AT_INCLUDE_PATH . 'footer.inc.php';
$description = $videoinfo['description']; $bigimage = $videoinfo['bigimage']; } else { die('没有指定播放的视频!'); } ?> <div class="video-center"> <div id="videoRight" class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title">相关视频</h4> </div> <div class="panel-body"> <?php $cat = get_cat_info($_GET['id']); for ($i = 0; $i < count($cat); $i++) { echo '<a title="' . $cat[$i]['title'] . '" href="' . $cat[$i]['url'] . '"><img class="relate-video" src="' . $cat[$i]['smallimage'] . '"/></a>'; } ?> </div> </div> <div id="videoCenter" class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title"><?php echo $description; ?> </h4> </div> <div class="panel-body">
/** * Generates breadcrumb for a category. * @see get_cat_display_name() * * @param int $cat_id * @param string|null $url * @return string */ function get_cat_display_name_from_id($cat_id, $url = '') { $cat_info = get_cat_info($cat_id); return get_cat_display_name($cat_info['upper_names'], $url); }
/** * 分类商品代表图片 * @param int $catid 商品分类id */ function upload_category_pic($catid) { /* 允许上传的文件类型 */ $allow_file_types = '|GIF|JPG|PNG|BMP|'; foreach ($_FILES as $code => $file) { /* 判断用户是否选择了文件 */ if (isset($file['error']) && $file['error'] == 0 || !isset($file['error']) && $file['tmp_name'] != 'none') { /* 检查上传的文件类型是否合法 */ if (!check_file_type($file['tmp_name'], $file['name'], $allow_file_types)) { sys_msg(sprintf($_LANG['msg_invalid_file'], $file['name'])); } else { $file_name = "../data/supplier/category/"; if ($code == 'cat_pic') { $ext = array_pop(explode('.', $file['name'])); $file_name .= $_SESSION['supplier_id'] . 'c' . time() . '.' . $ext; if ($catid > 0) { $catpic = get_cat_info($catid); if (file_exists($catpic['cat_pic'])) { @unlink($catpic['cat_pic']); } } } /* 判断是否上传成功 */ if (move_upload_file($file['tmp_name'], $file_name)) { return $file_name; } else { sys_msg(sprintf($_LANG['msg_upload_failed'], $file['name'], $file_name)); } } } } }
$order = (isset($_REQUEST['order']) && in_array(trim(strtoupper($_REQUEST['order'])), array('ASC', 'DESC'))) ? trim($_REQUEST['order']) : $default_sort_order_method; $display = (isset($_REQUEST['display']) && in_array(trim(strtolower($_REQUEST['display'])), array('list', 'grid', 'text'))) ? trim($_REQUEST['display']) : (isset($_COOKIE['ECS']['display']) ? $_COOKIE['ECS']['display'] : $default_display_type); $display = in_array($display, array('list', 'grid', 'text')) ? $display : 'text'; setcookie('ECS[display]', $display, gmtime() + 86400 * 7); /* 页面的缓存ID */ $cache_id = sprintf('%X', crc32($cat_id . '-' . $display . '-' . $sort .'-' . $order .'-' . $page . '-' . $size . '-' . $_SESSION['user_rank'] . '-' . $_CFG['lang'] . '-' . $integral_max . '-' .$integral_min)); if (!$smarty->is_cached('exchange.dwt', $cache_id)) { /* 如果页面没有被缓存则重新获取页面的内容 */ $children = get_children($cat_id); $cat = get_cat_info($cat_id); // 获得分类的相关信息 if (!empty($cat)) { $smarty->assign('keywords', htmlspecialchars($cat['keywords'])); $smarty->assign('description', htmlspecialchars($cat['cat_desc'])); } assign_template(); $position = assign_ur_here('exchange'); $smarty->assign('page_title', $position['title']); // 页面标题 $smarty->assign('ur_here', $position['ur_here']); // 当前位置 $smarty->assign('categories', get_categories_tree()); // 分类树 $smarty->assign('helps', get_shop_help()); // 网店帮助
public function search () { /** * 参数描述: * @var id 分类id. * @var page 当前页. * @var brand 品牌id. * @var price_max 最高价格. * @var price_min 最低价格. * @var order 排序方式. @enum.<'ASC', 'DESC'> * @var sort 排序字段.@enum.<'goods_id', 'shop_price', 'last_update'> * @var filter_attr table goods_attr 中goods_attr_id使用"."连接。例如9.10.11 */ global $_CFG,$ecs,$db; $cat_id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; if (!$cat_id) { $result = rpcLang('category.php', 'goodslist_failure'); jsonExit("{\"status\":\"$result\"}"); } $cat = get_cat_info($cat_id); // 获得分类的相关信息 if (empty($cat)) { $result = rpcLang('category.php', 'search_cat_failure'); jsonExit("{\"status\":\"$result\"}"); } $page = isset($_REQUEST['page']) && intval($_REQUEST['page']) > 0 ? intval($_REQUEST['page']) : 1; // $size = isset($_CFG['page_size']) && intval($_CFG['page_size']) > 0 ? intval($_CFG['page_size']) : 1; $size = 10; //品牌筛选. $brand = isset($_REQUEST['brand']) && intval($_REQUEST['brand']) > 0 ? intval($_REQUEST['brand']) : 0; //价格区间 $price_max = isset($_REQUEST['price_max']) && intval($_REQUEST['price_max']) > 0 ? intval($_REQUEST['price_max']) : 0; $price_min = isset($_REQUEST['price_min']) && intval($_REQUEST['price_min']) > 0 ? intval($_REQUEST['price_min']) : 0; //属性筛选.格式1.2.3 / attr_id使用.分割 $filter_attr_str = isset($_REQUEST['filter_attr']) ? htmlspecialchars(trim($_REQUEST['filter_attr'])) : '0'; $filter_attr_str = urldecode($filter_attr_str); $filter_attr = empty($filter_attr_str) ? '' : explode('.', trim($filter_attr_str)); /* 排序、方式及类型 */ $default_sort_order_method = $_CFG['sort_order_method'] == '0' ? 'DESC' : 'ASC'; $default_sort_order_type = $_CFG['sort_order_type'] == '0' ? 'goods_id' : ($_CFG['sort_order_type'] == '1' ? 'shop_price' : 'last_update'); $sort = (isset($_REQUEST['sort']) && in_array(trim(strtolower($_REQUEST['sort'])), array('goods_id', 'shop_price', 'last_update'))) ? trim($_REQUEST['sort']) : $default_sort_order_type; $order = (isset($_REQUEST['order']) && in_array(trim(strtoupper($_REQUEST['order'])), array('ASC', 'DESC'))) ? trim($_REQUEST['order']) : $default_sort_order_method; $children = get_children($cat_id); //属性筛选 $ext = ''; if (!empty($filter_attr)) { $ext_sql = "SELECT DISTINCT(b.goods_id) FROM " . $ecs->table('goods_attr') . " AS a, " . $ecs->table('goods_attr') . " AS b " . "WHERE "; $ext_group_goods = array(); foreach ($filter_attr AS $k => $v)// 查出符合所有筛选属性条件的商品id */ { if (!is_numeric($v) || $v == 0) continue; $sql = $ext_sql . "b.attr_value = a.attr_value AND a.goods_attr_id = " . $v; $ext_group_goods = $db->getColCached($sql); $ext .= ' AND ' . db_create_in($ext_group_goods, 'g.goods_id'); } } $count = get_cagtegory_goods_count($children, $brand, $price_min, $price_max, $ext); $max_page = ($count> 0) ? ceil($count / $size) : 1; if ($page > $max_page) $page = $max_page; $goodslist = category_get_goods($children, $brand, $price_min, $price_max, $ext, $size, $page, $sort, $order); if (!$goodslist) { $goodslist = rpcLang('category.php', 'goodslist_empty'); } $goodslist = array_values($goodslist); $pager = get_pager('category.php', $_GET, $count, $page, $size); //print_r(array('goods_list'=>$goodslist, 'pager'=>$pager));exit; jsonExit(array('goods_list'=>$goodslist, 'pager'=>$pager)); }
if (count($page['cat_elements_id']) > 0) { $nav_bar = create_navigation_bar($base_url . get_query_string_diff(array('start')), count($page['cat_elements_id']), $page['start'], $page['nb_images']); $template->assign(array('navbar' => $nav_bar)); $element_ids = array(); $is_category = false; if (isset($_SESSION['bulk_manager_filter']['category']) and !isset($_SESSION['bulk_manager_filter']['category_recursive'])) { $is_category = true; } if (isset($_SESSION['bulk_manager_filter']['prefilter']) and 'duplicates' == $_SESSION['bulk_manager_filter']['prefilter']) { $conf['order_by'] = ' ORDER BY file, id'; } $query = ' SELECT * FROM ' . IMAGES_TABLE; if ($is_category) { $category_info = get_cat_info($_SESSION['bulk_manager_filter']['category']); $conf['order_by'] = $conf['order_by_inside_category']; if (!empty($category_info['image_order'])) { $conf['order_by'] = ' ORDER BY ' . $category_info['image_order']; } $query .= ' JOIN ' . IMAGE_CATEGORY_TABLE . ' ON id = image_id'; } $query .= ' WHERE id IN (' . implode(',', $page['cat_elements_id']) . ')'; if ($is_category) { $query .= ' AND category_id = ' . $_SESSION['bulk_manager_filter']['category']; } $query .= ' ' . $conf['order_by'] . '
/** * the reverse of make_section_in_url * returns the 'section' (categories/tags/...) and the data associated with it * * Depending on section, other parameters are returned (category/tags/list/...) * * @param array of url tokens to parse * @param int the index in the array of url tokens; in/out * @return array */ function parse_section_url($tokens, &$next_token) { $page = array(); if (strncmp(@$tokens[$next_token], 'categor', 7) == 0) { $page['section'] = 'categories'; $next_token++; if (isset($tokens[$next_token])) { if (preg_match('/^(\\d+)(?:-(.+))?$/', $tokens[$next_token], $matches)) { if (isset($matches[2])) { $page['hit_by']['cat_url_name'] = $matches[2]; } $page['category'] = $matches[1]; $next_token++; } else { // try a permalink $maybe_permalinks = array(); $current_token = $next_token; while (isset($tokens[$current_token]) and strpos($tokens[$current_token], 'created-') !== 0 and strpos($tokens[$current_token], 'posted-') !== 0 and strpos($tokens[$next_token], 'start-') !== 0 and strpos($tokens[$next_token], 'startcat-') !== 0 and $tokens[$current_token] != 'flat') { if (empty($maybe_permalinks)) { $maybe_permalinks[] = $tokens[$current_token]; } else { $maybe_permalinks[] = $maybe_permalinks[count($maybe_permalinks) - 1] . '/' . $tokens[$current_token]; } $current_token++; } if (count($maybe_permalinks)) { $cat_id = get_cat_id_from_permalinks($maybe_permalinks, $perma_index); if (isset($cat_id)) { $next_token += $perma_index + 1; $page['category'] = $cat_id; $page['hit_by']['cat_permalink'] = $maybe_permalinks[$perma_index]; } else { page_not_found(l10n('Permalink for album not found')); } } } } if (isset($page['category'])) { $result = get_cat_info($page['category']); if (empty($result)) { page_not_found(l10n('Requested album does not exist')); } $page['category'] = $result; } } elseif ('tags' == @$tokens[$next_token]) { global $conf; $page['section'] = 'tags'; $page['tags'] = array(); $next_token++; $i = $next_token; $requested_tag_ids = array(); $requested_tag_url_names = array(); while (isset($tokens[$i])) { if (strpos($tokens[$i], 'created-') === 0 or strpos($tokens[$i], 'posted-') === 0 or strpos($tokens[$i], 'start-') === 0) { break; } if ($conf['tag_url_style'] != 'tag' and preg_match('/^(\\d+)(?:-(.*)|)$/', $tokens[$i], $matches)) { $requested_tag_ids[] = $matches[1]; } else { $requested_tag_url_names[] = $tokens[$i]; } $i++; } $next_token = $i; if (empty($requested_tag_ids) && empty($requested_tag_url_names)) { bad_request('at least one tag required'); } $page['tags'] = find_tags($requested_tag_ids, $requested_tag_url_names); if (empty($page['tags'])) { page_not_found(l10n('Requested tag does not exist'), get_root_url() . 'tags.php'); } } elseif ('favorites' == @$tokens[$next_token]) { $page['section'] = 'favorites'; $next_token++; } elseif ('most_visited' == @$tokens[$next_token]) { $page['section'] = 'most_visited'; $next_token++; } elseif ('best_rated' == @$tokens[$next_token]) { $page['section'] = 'best_rated'; $next_token++; } elseif ('recent_pics' == @$tokens[$next_token]) { $page['section'] = 'recent_pics'; $next_token++; } elseif ('recent_cats' == @$tokens[$next_token]) { $page['section'] = 'recent_cats'; $next_token++; } elseif ('search' == @$tokens[$next_token]) { $page['section'] = 'search'; $next_token++; preg_match('/(\\d+)/', @$tokens[$next_token], $matches); if (!isset($matches[1])) { bad_request('search identifier is missing'); } $page['search'] = $matches[1]; $next_token++; } elseif ('list' == @$tokens[$next_token]) { $page['section'] = 'list'; $next_token++; $page['list'] = array(); // No pictures if (empty($tokens[$next_token])) { // Add dummy element list $page['list'][] = -1; } else { if (!preg_match('/^\\d+(,\\d+)*$/', $tokens[$next_token])) { bad_request('wrong format on list GET parameter'); } foreach (explode(',', $tokens[$next_token]) as $image_id) { $page['list'][] = $image_id; } } $next_token++; } return $page; }
// 清除缓存 /*添加链接*/ $link[0]['text'] = $_LANG['continue_add']; $link[0]['href'] = 'category.php?act=add'; $link[1]['text'] = $_LANG['back_list']; $link[1]['href'] = 'category.php?act=list'; sys_msg($_LANG['catadd_succed'], 0, $link); } } /*------------------------------------------------------ */ //-- 编辑商品分类信息 /*------------------------------------------------------ */ if ($_REQUEST['act'] == 'edit') { admin_priv('cat_manage'); // 权限检查 $cat_info = get_cat_info(intval($_REQUEST['cat_id'])); // 查询分类信息数据 $attr_list = get_attr_list(); if ($cat_info['filter_attr']) { $attr_cat_id = $db->getOne("SELECT cat_id FROM " . $ecs->table('attribute') . " WHERE attr_id = '{$cat_info['filter_attr']}'"); $attr_option = array(); foreach ($attr_list[$attr_cat_id] as $val) { $attr_option[key($val)] = current($val); } $smarty->assign('attr_option', $attr_option); } else { $attr_cat_id = 0; } /* 模板赋值 */ $smarty->assign('goods_type_list', goods_type_list($attr_cat_id)); // 取得商品类型
//Check length of the post, if it's exceeded 64 as defined in the db. $_POST['title'] = validate_length($_POST['title'], 64); $_POST['description'] = validate_length($_POST['description'], 250); // $name = get_display_name($_SESSION['member_id']); $email = ''; //check if new cat is auth? -- shouldn't be a prob. since cat dropdown is already filtered queryDB('UPDATE %slinks SET cat_id=%d, Url="%s", LinkName="%s", Description="%s", Approved=%s WHERE link_id=%d', array(TABLE_PREFIX, $_POST['cat'], $_POST['url'], $_POST['title'], $_POST['description'], $_POST['approved'], $link_id)); $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY'); header('Location: ' . AT_BASE_HREF . 'mods/_standard/links/tools/index.php'); exit; } } else { $row = queryDB('SELECT * FROM %slinks WHERE link_id=%d', array(TABLE_PREFIX, $link_id), true); if (!empty($row)) { //auth based on the link's cat $cat_row = get_cat_info($row['cat_id']); if (!links_authenticate($cat_row['owner_type'], $cat_row['owner_id'])) { $msg->addError('ACCESS_DENIED'); header('Location: ' . AT_BASE_HREF . 'mods/_standard/links/tools/index.php'); exit; } $_POST['title'] = $row['LinkName']; $_POST['cat'] = $row['cat_id']; $_POST['url'] = $row['Url']; $_POST['description'] = $row['Description']; $_POST['approved'] = $row['Approved']; } } } $onload = 'document.form.title.focus();'; require AT_INCLUDE_PATH . 'header.inc.php';
/*添加链接*/ $link[0]['text'] = $_LANG['continue_add']; $link[0]['href'] = 'category.php?act=add'; $link[1]['text'] = $_LANG['back_list']; $link[1]['href'] = 'category.php?act=list'; sys_msg($_LANG['catadd_succed'], 0, $link); } } /*------------------------------------------------------ */ //-- 编辑商品分类信息 /*------------------------------------------------------ */ if ($_REQUEST['act'] == 'edit') { admin_priv('cat_manage'); // 权限检查 $cat_id = intval($_REQUEST['cat_id']); $cat_info = get_cat_info($cat_id); // 查询分类信息数据 $attr_list = get_attr_list(); $filter_attr_list = array(); if ($cat_info['filter_attr']) { $filter_attr = explode(",", $cat_info['filter_attr']); //把多个筛选属性放到数组中 foreach ($filter_attr as $k => $v) { $attr_cat_id = $db->getOne("SELECT cat_id FROM " . $ecs->table('attribute') . " WHERE attr_id = '" . intval($v) . "'"); $filter_attr_list[$k]['goods_type_list'] = goods_type_list($attr_cat_id); //取得每个属性的商品类型 $filter_attr_list[$k]['filter_attr'] = $v; $attr_option = array(); foreach ($attr_list[$attr_cat_id] as $val) { $attr_option[key($val)] = current($val); }
function pshare_section_init() { global $tokens, $page, $conf, $user, $template; if ($tokens[0] == 'pshare') { $page['section'] = 'pshare'; $page['title'] = l10n('Shared Picture'); if (!isset($tokens[1])) { die("missing key"); } if (!preg_match(PSHARE_KEY_PATTERN, $tokens[1])) { die("invalid key"); } $page['pshare_key'] = $tokens[1]; $query = ' SELECT *, NOW() AS dbnow FROM ' . PSHARE_KEYS_TABLE . ' WHERE uuid = \'' . $page['pshare_key'] . '\' ;'; $shares = query2array($query); if (count($shares) == 0) { die('unknown key'); } $share = $shares[0]; pshare_log($share['pshare_key_id'], 'visit'); // is the key still valid? if (strtotime($share['expire_on']) < strtotime($share['dbnow'])) { die('expired key'); } // if the user is permitted for this photo, let's redirect to // picture.php (with full details and actions) if (!is_a_guest() and pshare_is_photo_visible($share['image_id'])) { // find the first reachable category linked to the photo $query = ' SELECT category_id FROM ' . IMAGE_CATEGORY_TABLE . ' WHERE image_id = ' . $share['image_id'] . ' ;'; $authorizeds = array_diff(array_from_query($query, 'category_id'), explode(',', calculate_permissions($user['id'], $user['status']))); foreach ($authorizeds as $category_id) { $url = make_picture_url(array('image_id' => $share['image_id'], 'category' => get_cat_info($category_id))); if (function_exists('Fotorama_is_replace_picture') and Fotorama_is_replace_picture()) { $url .= '&slidestop'; } redirect($url); } redirect(make_picture_url(array('image_id' => $share['image_id']))); } $query = ' SELECT * FROM ' . IMAGES_TABLE . ' WHERE id = ' . $share['image_id'] . ' ;'; $rows = query2array($query); $image = $rows[0]; $src_image = new SrcImage($image); if (isset($tokens[2]) && 'download' == $tokens[2]) { $format_id = null; if (isset($tokens[3]) && preg_match('/^f(\\d+)$/', $tokens[3], $matches)) { $format_id = $matches[1]; $query = ' SELECT * FROM ' . IMAGE_FORMAT_TABLE . ' WHERE format_id = ' . $format_id . ' AND image_id = ' . $image['id'] . ' ;'; $formats = query2array($query); if (count($formats) == 0) { do_error(400, 'Invalid request - format'); } $format = $formats[0]; $file = original_to_format(get_element_path($image), $format['ext']); $image['file'] = get_filename_wo_extension($image['file']) . '.' . $format['ext']; } else { $file = $image['path']; } $gmt_mtime = gmdate('D, d M Y H:i:s', filemtime($file)) . ' GMT'; $http_headers = array('Content-Length: ' . @filesize($file), 'Last-Modified: ' . $gmt_mtime, 'Content-Type: ' . mime_content_type($file), 'Content-Disposition: attachment; filename="' . $image['file'] . '";', 'Content-Transfer-Encoding: binary'); foreach ($http_headers as $header) { header($header); } readfile($file); pshare_log($share['pshare_key_id'], 'download', $format_id); exit; } $template->set_filename('shared_picture', realpath(PSHARE_PATH . 'template/shared_picture.tpl')); $derivative = new DerivativeImage(ImageStdParams::get_by_type(IMG_MEDIUM), $src_image); $derivative_size = $derivative->get_size(); // a random string to avoid browser cache $rand = '&download=' . substr(md5(time()), 0, 6); $template->assign(array('SRC' => $derivative->get_url(), 'IMG_WIDTH' => $derivative_size[0], 'IMG_HEIGHT' => $derivative_size[1], 'DOWNLOAD_URL' => duplicate_index_url() . '/' . $page['pshare_key'] . '/download' . $rand)); // formats if (defined('IMAGE_FORMAT_TABLE')) { $query = ' SELECT * FROM ' . IMAGE_FORMAT_TABLE . ' WHERE image_id = ' . $share['image_id'] . ' ;'; $formats = query2array($query); if (!empty($formats)) { foreach ($formats as &$format) { $format['download_url'] = duplicate_index_url() . '/' . $page['pshare_key'] . '/download'; $format['download_url'] .= '/f' . $format['format_id'] . $rand; $format['filesize'] = sprintf('%.1fMB', $format['filesize'] / 1024); } } $template->assign('formats', $formats); } $template->parse('shared_picture'); $template->p(); exit; } }