$conf, $time;
$_uid = user_token_get_do();
empty($_uid) and user_token_clear(); // 退出登录
return $_uid;
}
// 用户
function user_token_get_do()
{
global $conf, $time, $ip, $useragent;
$token = param($conf['cookie_pre'] . 'token');
if (empty($token)) return FALSE;
$tokenkey = md5(xn_key());
$s = xn_decrypt($token, $tokenkey);
if (empty($s)) return FALSE;
$arr = explode("\t", $s);
if (count($arr) != 5) return FALSE;
list($_ip, $_time, $_uid, $_pwd, $ua_md5) = $arr;
if (array_value($conf, 'login_ip') && $ip != $_ip) return FALSE;
if (array_value($conf, 'login_ua') && md5($useragent) != $ua_md5) return FALSE;
$_user = user_read($_uid);
if (empty($_user)) return FALSE;
if (array_value($conf, 'login_only') && $_user['login_date'] != $_time) return FALSE;
// 密码是否被修改
if (md5($_user['password']) != $_pwd) return FALSE;
return $_uid;
}
// 设置 token,防止 sid 过期后被删除
function user_token_set($uid)
{
global $conf, $time;
if (empty($uid)) return '';
$token = user_token_gen($uid);
setcookie($conf['cookie_pre'] . 'token', $token, $time + 86400000, $conf['cookie_path'], $conf['cookie_domain'], '', TRUE);
return $token;
}
function user_token_clear()
{
global $conf, $time;
setcookie($conf['cookie_pre'] . 'token', '', $time - 8640000, $conf['cookie_path'], $conf['cookie_domain'], '', TRUE);
}
function user_token_gen($uid)
{
global $conf, $time, $ip, $useragent;
$key = 'user_token' . $uid;
static $cache = array();
if (isset($cache[$key])) return $cache[$key];
$user = user_read($uid);
$pwd = md5($user['password']);
$ua_md5 = md5($useragent);
$tokenkey = md5(xn_key());
$cache[$key] = xn_encrypt("$ip $time $uid $pwd $ua_md5", $tokenkey);
return $cache[$key];
}
// 前台登录验证
function user_login_check()
{
global $user;
empty($user) and http_location(url('user-login'));
}
// 获取用户来路
function user_http_referer()
{
global $conf;
$referer = param('referer'); // 优先从参数获取 | GET is priority
empty($referer) and $referer = array_value($_SERVER, 'HTTP_REFERER', '');
$referer = str_replace(array('\"', '"', '<', '>', ' ', '*', "\t", "\r", "\n"), '', $referer); // 干掉特殊字符 strip special chars
if (
!preg_match('#^(http|https)://[\w\-=/\.]+/[\w\-=.%\#?]*$#is', $referer)
|| FALSE !== strpos($referer, url('user-login'))
|| FALSE !== strpos($referer, url('user-logout'))
|| FALSE !== strpos($referer, url('user-create'))
|| FALSE !== strpos($referer, url('user-setpw'))
|| FALSE !== strpos($referer, url('user-resetpw_complete'))
) {
$referer = $conf['path'];
}
return $referer;
}
function user_auth_check($token)
{
global $time, $ip;
$auth = param(2);
$s = xn_decrypt($auth);
empty($s) and message(-1, lang('decrypt_failed'));
$arr = explode('-', $s);
count($arr) != 4 and message(-1, lang('encrypt_failed'));
list($_ip, $_time, $_uid, $_pwd) = $arr;
$_user = user_read($_uid);
empty($_user) and message(-1, lang('user_not_exists'));
$time - $_time > 3600 and message(-1, lang('link_has_expired'));
return $_user;
}
?>权限没有,则隐藏
function forum_list_access_filter($forumlist, $gid, $allow = 'allowread')
{
global $grouplist;
if (empty($forumlist)) return array();
if (1 == $gid) return $forumlist;
$forumlist_filter = $forumlist;
$group = $grouplist[$gid];
foreach ($forumlist_filter as $fid => $forum) {
if (empty($forum['accesson']) && empty($group[$allow]) || !empty($forum['accesson']) && empty($forum['accesslist'][$gid][$allow])) {
unset($forumlist_filter[$fid]);
}
unset($forumlist_filter[$fid]['accesslist']);
}
return $forumlist_filter;
}
function forum_filter_moduid($moduids)
{
$moduids = trim($moduids);
if (empty($moduids)) return '';
$arr = explode(',', $moduids);
$r = array();
foreach ($arr as $_uid) {
$_uid = intval($_uid);
$_user = user_read($_uid);
if (empty($_user)) continue;
if ($_user['gid'] > 4) continue;
$r[] = $_uid;
}
return implode(',', $r);
}
function forum_safe_info($forum)
{
//unset($forum['moduids']);
return $forum;
}
function forum_filter($forumlist)
{
foreach ($forumlist as &$val) {
unset($val['brief'], $val['announcement'], $val['seo_title'], $val['seo_keywords'], $val['create_date_fmt'], $val['icon_url'], $val['modlist']);
}
return $forumlist;
}
function forum_format_url($forum)
{
global $conf;
if (0 == $forum['category']) {
// 列表URL
$url = url('list-' . $forum['fid'], '', FALSE);
} elseif (1 == $forum['category']) {
// 频道
$url = url('category-' . $forum['fid'], '', FALSE);
} elseif (2 == $forum['category']) {
// 单页
$url = url('read-' . trim($forum['brief']), '', FALSE);
}
if ($conf['url_rewrite_on'] > 1 && $forum['well_alias']) {
if (0 == $forum['category'] || 1 == $forum['category']) {
$url = url($forum['well_alias'], '', FALSE);
} elseif (2 == $forum['category']) {
// 单页
$url = ($forum['threads'] && $forum['brief']) ? url($forum['well_alias'] . '-' . trim($forum['brief']), '', FALSE) : url($forum['well_alias'], '', FALSE);
}
}
return $url;
}
function well_forum_alias()
{
$forumlist = forum_list_cache();
if (empty($forumlist)) return '';
$key = 'forum-alias';
static $cache = array();
if (isset($cache[$key])) return $cache[$key];
$cache[$key] = array();
foreach ($forumlist as $val) {
if ($val['well_alias']) $cache[$key][$val['fid']] = $val['well_alias'];
}
return array_flip($cache[$key]);
}
function well_forum_alias_cache()
{
global $conf;
$key = 'forum-alias-cache';
static $cache = array(); // 用静态变量只能在当前 request 生命周期缓存,跨进程需要再加一层缓存:redis/memcached/xcache/apc
if (isset($cache[$key])) return $cache[$key];
if ('mysql' == $conf['cache']['type']) {
$arr = well_forum_alias();
} else {
$arr = cache_get($key);
if (NULL === $arr) {
$arr = well_forum_alias();
!empty($arr) AND cache_set($key, $arr);
}
}
$cache[$key] = empty($arr) ? '' : $arr;
return $cache[$key];
}
?>return FALSE;
$r = well_tag_thread__update(array('id' => $id), $update);
return $r;
}
function well_tag_thread_find($tagid, $page, $pagesize)
{
$arr = well_tag_thread__find(array('tagid' => $tagid), array('id' => -1), $page, $pagesize);
return $arr;
}
function well_tag_thread_find_by_tid($tid, $page, $pagesize)
{
$arr = well_tag_thread__find(array('tid' => $tid), array(), $page, $pagesize);
return $arr;
}
?>
《网页设计与制作基础》实验指导书编程频道|福州电脑网
《网页设计与制作基础》实验指导书
系统教程490
更新时间:2026-04-09 22:39:27 2024年4月29日发(作者:)
实验一 网页的认识
实验目的
1、 掌握利用Internet进行信息游览、搜索,下载网页、图片、文字和文件;
2、 利用记事本来编辑HTML文档并浏览。
3、 熟悉HTML基本标记的使用。
实验环境
WindowsXP操作系统,内部组成局域网,外连Internet互联网。
实验重点及难点
熟悉HTML的结构、语法。
熟悉HTML基本标记的使用。
实验内容
1、 从网上(如网页制作大宝库等)下载网页制作时需
要的小图片、动画及flash等网页制作素材。
2、 收集你认为比较好的网页并从网页主题、网页内容、结构布局、色彩搭配等方面
来分析网页。
3、 通过浏览新浪网站主页分析其网页基本元素,查看其源代码,收藏到收藏夹中,
将其设为主页。
4、 制作一个简单的网页,用记事本编辑,网页标题为“熟悉HTML文
档的结构”,内容为司空曙的《江村即事》,如下图所示。
5、 通过附录1的练习熟悉HTML基本标记的使用。(可参考第二章内容)
本文发布于:2024-04-29,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网页制作基本实验
发布评论