新闻发布管理系统--实习报告内容摘要:

$re[39。 gbk39。 ] = /[\x01\x7f]|[\x81\xfe][\x40\xfe]/。 $re[39。 big539。 ] = /[\x01\x7f]|[\x81\xfe]([\x40\x7e]|\xa1\xfe])/。 preg_match_all($re[$charset], $str, $match)。 if(count($match[0]) = $length) return $str。 $slice = join(,array_slice($match[0], $start, $length))。 } if($suffix) return $slice.…。 return $slice。 } /*******操作提示跳转页 ******/ function show_msg($url, $show = 39。 操作已成功。 39。 ,$open=self){ $msg = 39。 !DOCTYPE html PUBLIC //W3C//DTD XHTML Transitional//EN html xmlns= meta equiv=ContentType content=text/html。 charset=utf8 / script type=text/javascript setTimeout(goto(),2020)。 function goto(){ 39。 .$open.39。 .=39。 .$url.39。 } /script title管理区域 /title /head body div id=man_zone table width=40% border=1 align=center cellpadding=3 cellspacing=0 class=table style=margintop:100px。 bordercollapse:collapse。 tr th align=center style=background:cef信息提示 /th /tr tr tdpfont color=ff000039。 . $show . 39。 /fontbr / 2秒后返回指定页面。 br / 如果浏览器无法跳转, a href=39。 . $url . 39。 target=_39。 .$open.39。 请点击此处 /a。 /p/td /tr /table /div /body /html39。 echo $msg。 exit ()。 } ? 用户注册的设计与实现 前台用户注册 ?php include_once()。 /********用户注册 ***********/ $db=new mypdo()。 if(isset($_POST[39。 submit39。 ])){ $rs=$dbprepare(INSERT INTO `np_user` (`username`, `password`, ``) VALUES (?, ?, ?))。 $rsexecute(array($_POST[39。 username39。 ],md5($_POST[39。 password39。 ].ALLPS),$_POST[39。 39。 ]))。 show_msg(,恭喜您,注册成功,请登录 )。 } $smartydisplay()。 ? 用到 jquery的插件 validate , // JavaScript Document $(function(){ //自定义验证 $.(stringCheck, function(value, element) { return (element) || /^[\u0391\uFFE5\w]+$/.test(value)。 }, 只能包括中文字、英文字母、数字和下划线 )。 $(reg).validate({ rules:{ username:{ required:true, minlength:5, stringCheck:true, remote: }, password:{ required:true, minlength:5 }, { required:true, true }, password2:{ required:true, minlength:5, equalTo: password } }, messages:{ username:{ required:请输入用户名 , minlength:用户名太短了点 , remote:该用户名已经被注册了 }, password:{ required:请输入密码名 , minlength:用户密码太短了点 }, { required:请输入 , 格式不正确哦 }, password2:{ equalTo:请 输入相同的密码 } }, errorElement:em, success:function(em){ ( ).addClass(success) } }) }) 调用的 ajax ?php include_once (39。 ./mon/39。 )。 session_start()。 $db=new mypdo()。 if(isset($_GET[39。 username39。 ])){ //用户名验证 $db=new mypdo()。 $rs=$dbprepare(SELECT * FROM `np_user` WHERE `username`= ?)。 $rsexecute(array($_GET[39。 username39。 ]))。 $row=$rsfetch()。 if(is_array($row)){ echo false。 }else{ echo true。 } } if(!empty($_POST[39。 vote_button39。 ])){ foreach(array_filter($_POST[39。 id39。 ]) as $id){ $rs_t=$dbprepare(UPDATE `newsphp`.`np_item` SET `hit` = hit+1 WHERE `np_item`.`id` = ?)。 if(@$_COOKIE[$id]!=$id){ $rs_texecute(array($id))。 setcookie($id,$id,time()+1800)。 } } } ? 实现了如下效果: 用户收藏新闻的设计写实现 未完成 后台管理员的权限的设计 分五个等级: switch($row[39。 mid39。 ]){ case 0: $rule=拥有所有权限。 $level=创始人。 break。 case 1: $rule=拥有所有权限。 $level=超级管理员。 break。 case 2: $rule=可以对新闻,评论进行管理。 $level=普通管理员。 break。 case 3: $rule=可以管理新闻。 $level=新闻管理员。 break。 case 4。 $rule=可以管理评论。 $level=评论管理员。 break。 /***********用户权限判断 *************/ function user_check($uid,$shell,$mid=100){ $db=new mypdo()。 $rs=$dbprepare(select * from `np_admin` WHERE `id`= ?)。 $rsexecute(array($uid))。 $row=$rsfetch()。 $us=is_array($row)。 $pass=$us?$shell==md5($row[39。 username39。 ].$row[39。 password39。 ].ALLPS):false。 //验证密码 if($pass){ if($mid=$row[39。 mid39。 ]){ //权限判断 return $row。 }else{ show_msg(,你没用权限操作该页面 )。 exit()。 } }else{ show_msg(,请先登录 )。 exit()。 } } 新闻分类的设计与实现 本系统最难的地方,要实现无限分类 先写个无限分类的类, ?php /** * 通用无限分类 */ class tree { public $data=array()。 public $cateArray=array()。 function Tree() { } /***********输入类节点 ****************/ function setNode ($id, $parent, $value) { $parent = $parent?$parent:0。 $thisdata[$id] = $value。 $thiscateArray[$id] = $parent。 } /*************获取空值的节点树 array()******************/ function getChildsTree($id=0) { $childs=array()。 foreach ($thiscateArray as $child=$parent) { if ($parent==$id) { $childs[$child]=$thisgetChildsTree($child)。 } } return $childs。 } /**************获得所有分类 id**************/ function getChilds($id=0) { $childArray=array()。 $childs=$thisgetChild($id)。 foreach ($childs as $child) { $childArray[]=$child。 $childArray=array_merge($childArray,$thisgetChilds($child))。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。