Skip to content

Commit a06cf8a

Browse files
committed
init
0 parents  commit a06cf8a

17 files changed

+950
-0
lines changed

apply.htm

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2+
<html xmlns="http://www.w3.org/1999/xhtml">
3+
<head>
4+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5+
<title>用户注册</title>
6+
<style type="text/css">
7+
form{margin:0 auto; margin-top:100px; width:269px; height:88px;}
8+
span{margin-left:45px; width:114px; height:22px;}
9+
legend{font-size:24px;}
10+
</style>
11+
</head>
12+
13+
<body>
14+
<form action="login.php"; name="apply" method="post" id="form" onsubmit="return chenck();">
15+
<fieldset>
16+
<legend>用户注册</legend>
17+
用户名:<input id="usename" type="text" name="applyname"/><br />
18+
密&nbsp;&nbsp;码:<input id="password" type="password" name="applyword" /><br />
19+
&nbsp;<input id="login" type="submit" value="注册" name="apply" />
20+
&nbsp;<input id="reset" type="reset" value="重置" />
21+
</fieldset>
22+
</form>
23+
<center style="margin-top:50px;">Designed by Homker</center>
24+
</body>
25+
</html>
26+
<script type="text/javascript">
27+
function chenck()
28+
{
29+
if(apply.applyname.value=="")
30+
{
31+
alert("用户名不得为空");
32+
apply.applyname.focus();
33+
return false
34+
}
35+
if(apply.applyword.value=="")
36+
{
37+
alert("密码不得为空");
38+
apply.applyword.focus();
39+
return false
40+
}
41+
}
42+
</script>

apply_back.php

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
include 'conn.php';
3+
if(@$_POST['apply'])
4+
{
5+
//echo "this is a test";
6+
$applyname=$_POST['applyname'];
7+
$applyword=$_POST['applyword'];
8+
$applycheck= new check($conn,$applyname,$applyword);
9+
switch ($applycheck->cc) {
10+
case '1':
11+
{
12+
//echo "this is a test";
13+
$dbname="login";
14+
$applyin=new db($dbname);
15+
$value=array('LoginName'=>$applyname,'PassWord'=>$applyword,'Access'=>2);
16+
if($result=$applyin->insert($value)) echo "注册成功";
17+
else echo "you are fail~!";
18+
}
19+
break;
20+
default:
21+
echo "<script language=\"javascript\">alert('用户名被占用');</script>";break;
22+
break;
23+
}
24+
25+
}
26+
27+
?>

bg.htm

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2+
<html xmlns="http://www.w3.org/1999/xhtml">
3+
<head>
4+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5+
<title>后台操作</title>
6+
<style type="text/css">
7+
.floatl{float:left;}
8+
.floatr{float:right;}
9+
.clear{clear:both;}
10+
.title{ padding-left:100px; margin-top:5px;}
11+
.width{ width:350px;}
12+
.margintop{ margin-top:10px;}
13+
.marginleft{ margin-left:50px;}
14+
.marginleft_s{ margin-left:10px;}
15+
.marginright{ margin-right:300px;}
16+
.submit{ margin:10px 0 0 500px;}
17+
textarea{width:490px; height:50px;}
18+
.content{ margin:0 auto; width:908px;}
19+
li{list-style: none;}
20+
p{font-size:20px;}
21+
div{font-size: 14px;}
22+
.backcontent{width: 473px;}
23+
.top{ position:fixed; border:1px solid black; text-decoration: none; top:500px; left:1200px;}
24+
</style>
25+
</head>
26+
27+
<body>
28+
<?php include 'head.php' ?>
29+
<a href="#top" class="top"> top </a>
30+
<!--查看留言部分-->
31+
<div class="content margintop">
32+
<fieldset>
33+
<legend>查看话题</legend>
34+
<div class="session">
35+
<?php
36+
$bgstcontent=$bglist->fetch();
37+
while($result=mysql_fetch_array($bgstcontent))
38+
{
39+
$ID=$result['ID'];
40+
$IDs="ContentID=$ID";
41+
?>
42+
<fieldset>
43+
<legend><?php echo $result['UName']?>说:</legend>
44+
<p><?php echo $result['Title']?></p>
45+
<div class="marginright floatl marginleft"><?php echo $result['Content']?></div>
46+
<span class="submit">回帖数<?php echo $click=$result['Click']?></span><span class="marginleft">时间:<?php echo $result['Time']?></span>
47+
<a class="marginleft_s" href="?ID=<?php echo $ID ?>">删除</a>
48+
</fieldset>
49+
<ul>
50+
<?php
51+
//var_dump($sscontent);
52+
$value="*";
53+
$bgsscontent=$bgsession->fetch($value,$IDs);
54+
while($sresult=mysql_fetch_array($bgsscontent))
55+
{
56+
$SID=$sresult['ID'];
57+
?>
58+
<li>
59+
<span><?php echo $sresult['UserName']?>说:<?php echo $sresult['Content']?></span>
60+
<a class="floatr marginleft_s" href="?SID=<?php echo $SID ?>">删除</a>
61+
<span class="floatr"><?php echo $sresult['Time']?></span>
62+
63+
</li>
64+
<?php } ?>
65+
</ul>
66+
<?php } ?>
67+
</div>
68+
</fieldset>
69+
</div>
70+
<!--发表留言部分-->
71+
<?php include 'footer.php' ?>
72+
</body>
73+
</html>

bg.php

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
include 'conn.php';
3+
if (@$_COOKIE['cookie']=='fy')
4+
{
5+
if (@$_SESSION['rt']=='1')
6+
{
7+
$list="list";
8+
$session="session";
9+
$bglist=new db($list);
10+
$bgsession=new db($session);
11+
include 'bg.htm';
12+
if (@$_GET['ID'])
13+
{
14+
$lcondition="ID=$ID";
15+
$scondition="ContentID=$ID";
16+
if($bglist->del($lcondition)&&$bgsession->del($scondition))
17+
echo "<script language=\"javascript\">alert('删除成功');location.href='bg.php';</script>";
18+
}
19+
if (@$_GET['SID'])
20+
{
21+
$scondition="ID=$SID";
22+
if($bgsession->del($scondition))
23+
echo "<script language=\"javascript\">alert('删除成功');location.href='bg.php';</script>";;
24+
}
25+
}
26+
else
27+
{
28+
echo "<script language=\"javascript\">
29+
alert('这个页面不是谁想看就能看的,小样去找管理员拿权限');
30+
location.href='list.php';
31+
</script>";
32+
}
33+
}
34+
else
35+
{
36+
echo "<script language=\"javascript\">
37+
alert('请先行登入');
38+
location.href='index.htm';
39+
</script>";
40+
}
41+
42+
?>

config.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
name: homker
3+
version: 1
4+
...

conn.php

+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
<?php
2+
header("Content-type:text/html;charset=utf-8");
3+
date_default_timezone_set('PRC');
4+
session_start();
5+
/* 连接到数据库 */
6+
$conn=mysql_connect(SAE_MYSQL_HOST_M.':'.SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS)or die("无法连接到服务器");
7+
$db=mysql_select_db(SAE_MYSQL_DB,$conn);
8+
$query=mysql_query("set names 'utf8'");
9+
if(@$_GET['out'])
10+
{
11+
setcookie("cookie","ann");
12+
echo "<script language=\"javascript\">location.href='index.htm';</script>";
13+
}
14+
/* 规范提交到数据库的html代码 */
15+
function htmlcode($contents)
16+
{
17+
$contents= str_replace("/n" , "<br/>", str_replace(" ","&nbsp;",$contents));
18+
return $contents;
19+
}
20+
21+
/* 建立一个可以写入数据和读出数据的类 */
22+
23+
class db
24+
{
25+
public $dbname;
26+
public $query;
27+
public $array;
28+
public $order="ID";
29+
public function __construct($dbname)
30+
{
31+
$this->dbname=$dbname;
32+
}
33+
public function insert($dataArray)
34+
{
35+
$field = "";
36+
$value = "";
37+
if( !is_array($dataArray) || count($dataArray)<=0)
38+
{
39+
$this->halt('没有要插入的数据');
40+
return false;
41+
}
42+
while(list($key,$val)=each($dataArray))
43+
{
44+
$field .="$key,";
45+
$value .="'$val',";
46+
}
47+
$field = substr( $field,0,-1);
48+
$value = substr( $value,0,-1);
49+
$sql = "insert into $this->dbname($field) values($value)";
50+
$this->query=mysql_query($sql);
51+
return $this->query;
52+
}
53+
54+
55+
/*public function insert($value)
56+
{
57+
58+
foreach ($value as $key => $value)
59+
{
60+
61+
}
62+
echo "INSERT INTO $this->dbname($key)values('$value')";
63+
64+
//}
65+
$this->query=mysql_query($sql);
66+
return $this->query;
67+
}*/
68+
69+
public function fetch($dbfield="*",$ID="1",$order="ID ASC")
70+
{
71+
$sql="SELECT $dbfield FROM $this->dbname WHERE $ID ORDER BY $order";
72+
$this->query=mysql_query($sql);
73+
return $this->query;
74+
}
75+
76+
public function del($condition)
77+
{
78+
$sql="DELETE FROM $this->dbname WHERE $condition ";
79+
$this->query=mysql_query($sql);
80+
return $this->query;
81+
}
82+
public function update($set,$condition)
83+
{
84+
$sql="UPDATE $this->dbname SET $set WHERE $condition";
85+
$this->query=mysql_query($sql);
86+
return $this->query;
87+
88+
}
89+
public function inchenck($usename,$content,$field="Content")
90+
{
91+
$sql="SELECT $field FROM $this->dbname WHERE $usename AND $field LIKE '%$content%'";
92+
$this->query=mysql_query($sql);
93+
$row=mysql_num_rows($this->query);
94+
if ($row>=3) return false;
95+
else return true;
96+
}
97+
};
98+
99+
/*******************权限认证*****************************/
100+
class check
101+
{
102+
public $cc;
103+
function __construct($conn,$usename,$password)//密码验证
104+
{
105+
$sql = "select * from login";
106+
$result = mysql_query($sql,$conn);
107+
$num = mysql_num_rows($result);
108+
$flag=0;
109+
while ($row = mysql_fetch_array($result))
110+
{
111+
if (($usename == @$row['LoginName'])&&($password == @$row['PassWord']))
112+
{
113+
$_SESSION['un'] = @$row['LoginName'];
114+
$_SESSION['rt'] = @$row['Access'];
115+
return ($this->cc=0); break;
116+
}
117+
elseif ($row['LoginName']!=$usename)
118+
{
119+
$flag++;
120+
if($flag==$num)
121+
{
122+
return ($this->cc=1);
123+
}
124+
}
125+
elseif((@$row['LoginName']==$usename)&&(@$row['PassWord']!=$password))
126+
{
127+
return ($this->cc=2);
128+
break;
129+
}
130+
}
131+
}
132+
}
133+
/////////////////////////////////////////the end of php
134+
////////////////////////////////////////power by homker
135+

footer.php

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<div class="footer">
2+
<hr/>
3+
<center style="margin-top:25px;">Designed by Homker</center>
4+
</div>

head.php

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
$usename=$_SESSION['un'];
4+
?>
5+
<div class="header">
6+
<span name="top" style="float:left">留言板扩展模型</span>
7+
<div>
8+
<span style="position:fixed; width:100%; left:1150px;">
9+
<a href="personal.php"><?php echo $usename ?></a>,你好&#9;
10+
<a class="backlist" href="list.php">回到列表</a>
11+
<a href="?out='login'">退出</a>
12+
</span>
13+
</div>
14+
<hr style="clear:both;"/>
15+
</div>

index.htm

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2+
<html xmlns="http://www.w3.org/1999/xhtml">
3+
<head>
4+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5+
<title>用户登入</title>
6+
<style type="text/css">
7+
form{margin:0 auto; margin-top:100px; width:269px; height:88px;}
8+
span{margin-left:45px; width:114px; height:22px;}
9+
legend{font-size:24px;}
10+
</style>
11+
</head>
12+
13+
<body>
14+
<form action="login.php"; method="post" id="form" name="login" onsubmit="return chenck();">
15+
<fieldset>
16+
<legend>登入验证</legend>
17+
用户名:<input id="usename" type="text" name="usename"/><br />
18+
密&nbsp;&nbsp;码:<input id="password" type="password" name="password" /><br />
19+
<input id="login" type="submit" value="登入" name="login" />
20+
<input id="reset" type="reset" value="重置" />
21+
<a href="apply.htm">注册</a>
22+
</fieldset>
23+
</form>
24+
<center style="margin-top:50px;">Designed by Homker</center>
25+
</body>
26+
</html>
27+
<script type="text/javascript">
28+
function chenck()
29+
{
30+
if(login.usename.value=="")
31+
{
32+
alert("用户名不得为空");
33+
login.usename.focus();
34+
return false;
35+
}
36+
if(login.password.value=="")
37+
{
38+
alert("密码不得为空");
39+
login.password.focus();
40+
return false;
41+
}
42+
}
43+
</script>

0 commit comments

Comments
 (0)