source/module/category.php

(开头部分) 5KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php
/** category path */
function get_category_path($cate_id = 0, $separator = ' &raquo; ') {
	global $DB;
	
	$cate = get_one_category($cate_id);
	if (!isset($cate)) return '';
	
	$sql = "SELECT cate_id, cate_mod, cate_name FROM ".$DB->table('categories')." WHERE cate_id IN (".$cate_id.','.$cate['cate_arrparentid'].")";
	$categories = $DB->fetch_all($sql);
	foreach ($categories as $row) {
		$strpath .= $separator.'<a href="'.get_category_url($row['cate_mod'], $row['cate_id']).'">'.$row['cate_name'].'</a>';
	}
	unset($cate, $categories);
	
	return $strpath;
}
	
/** category option */
function get_category_option($cate_mod = 'webdir', $root_id = 0, $cate_id = 0, $level_id = 0) {
	global $DB;
	
	if (!in_array($cate_mod, array('webdir', 'article'))) $cate_mod = 'webdir';
	$where = "root_id=$root_id AND cate_mod='$cate_mod'";
	$sql = "SELECT cate_id, cate_name FROM ".$DB->table('categories')." WHERE $where ORDER BY cate_order ASC, cate_id ASC";
	$results = $DB->fetch_all($sql);
	$optstr = '';
	foreach ($results as $row) {
		$optstr .= '<option value="'.$row['cate_id'].'"';
		if ($cate_id > 0 && $cate_id == $row['cate_id']) $optstr .= ' selected';
		
		if ($level_id == 0) {
			$optstr .= ' style="background: #EEF3F7;">';
			$optstr .= '├'.$row['cate_name'];
		} else {
			$optstr .= '>';
			for ($i = 2; $i <= $level_id; $i++) {
				$optstr .= '│&nbsp;&nbsp;';
			}
			$optstr .= '│&nbsp;&nbsp;├'.$row['cate_name'];
		}
		$optstr .= '</option>';
		$optstr .= get_category_option($cate_mod, $row['cate_id'], $cate_id, $level_id + 1);
	}
	unset($results);
		
	return $optstr;
}

/** categories */
function get_categories($cate_id = 0, $top_num = 0) {
	global $DB;
	
	$sql = "SELECT cate_id, cate_mod, cate_name, cate_childcount, cate_postcount FROM ".$DB->table('categories')." WHERE root_id=$cate_id ORDER BY cate_order ASC, cate_id ASC";
	if ($top_num > 0) $sql .= " LIMIT $top_num";
	$results = $DB->fetch_all($sql);
	$categories = array();
	foreach ($results as $row) {
		$row['cate_link'] = get_category_url($row['cate_mod'], $row['cate_id']);
		$categories[] = $row;
后面还有 114 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。