前一段时间参加了计算机作品竞赛和大夏杯,软件形式的作品和实物不同,可能需要先配置,像用MySQL控制台建数据库这种事情最好不要让用户和评委干,只有再麻烦自己为他们做一个方便的安装程序
为了让评委方便的安装配置上交的作品,特地上网学习了这种通过运行一个Web程序来达到安装效果的方式,其中包括了建立数据库,建表,添加演示数据,将配置信息写入配置文件等,对用户可实现一键搞定安装配置,很方便
现以本博客系统的安装程序为例,对其分析,首先是流程图
为了让评委方便的安装配置上交的作品,特地上网学习了这种通过运行一个Web程序来达到安装效果的方式,其中包括了建立数据库,建表,添加演示数据,将配置信息写入配置文件等,对用户可实现一键搞定安装配置,很方便
现以本博客系统的安装程序为例,对其分析,首先是流程图
install.php安装文件
1 # <?php
2 #
3 # function ErrorInfo() {
4 # return "<ul style='font-family:Courier;font-size:11px;background:#FDF5E6;color:#696969;margin:3px;padding:10px;border:1px solid #696969;'>Notice!: System Error<li style='font-family:Courier;list-style-type:none'>ErrInfo: ".mysql_error()."</li><li style='font-family:Courier;list-style-type:none'>ErrCode: ".mysql_errno()."</li><li style='font-family:Courier;list-style-type:none'>ErrURIs: ".$_SERVER['REQUEST_URI']."</li></ul>";
5 # }
6 #
7 # if (isset($_POST['install'])) { //提交创建
8 # echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
9 # $dbserver = $_POST['dbhost'].(isset($_POST['dbport']) ? ":".$_POST['dbport']:
10 # '');
11 # $conn = @mysql_connect($dbserver, $_POST['dbuser'], $_POST['dbpass'])or die
12 # (ErrorInfo()); //连接到MySQL Server
13 # if (!$conn) die(ErrorInfo());
14 # @mysql_query('set names gbk');
15 #
16 # if (isset($_POST['dropold']))
17 # @mysql_query("DROP DATABASE IF EXISTS `".$_POST['dbname']."` ;")or die
18 # (ErrorInfo());
19 # //按条件删除原DB
20 # echo '<div style="margin-left:300px;">';
21 # echo"<br />创建数据库 ";
22 # @mysql_query("CREATE DATABASE IF NOT EXISTS `".$_POST['dbname'].
23 # "` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;")or die(ErrorInfo());
24 # //创建DB
25 # echo"OK!";
26 # $linktodb = @mysql_select_db($_POST['dbname'], $conn)or die(ErrorInfo());
27 # //打开数据库
28 # echo"<br />创建数据表 ";
29 # if ($ftable = file_get_contents("table.sql")) { //fopen('table.sql', 'r')) { //创建表
30 # //while (!feof($ftable)) {
31 # $ftables = explode(";",$ftable);
32 # for($i = 0;$i < count($ftables);$i++) {
33 # if($ftables[$i] == "") continue;
34 # @mysql_query($ftables[$i]) or die(ErrorInfo());
35 # //echo fgets($ftable)."<br>";
36 # //}
37 # //echo $i.$ftables[$i]."<br>";
38 # echo"成功!";
39 # //fclose($ftable);
40 # }
41 # } else { //不能创建表或者创建有误
42 # echo"失败!";
43 # echo"<br />删除原有数据库 ";
44 # @mysql_query("DROP DATABASE IF EXISTS ".$_POST['dbname']." ;")or die(ErrorInfo()); //删除所创建DB
45 # echo"OK!";
46 # exit();
47 # }
48 #
49 # if ($fp = fopen("../dbconnect.inc.php", 'w+')) {
50 # $configstr = "<?php\n//数据库信息\ndefine('DBHOST','".$dbserver."');\t\t//数据库服务器\ndefine('DBUSER','".$_POST['dbuser']."');\t\t\t\t//数据库用户\ndefine('DBPASS','".$_POST['dbpass']."');\t //数据库用户密码\ndefine('DBNAME','".$_POST['dbname']."');\t\t\t//数据库名称\n//连接到数据库\n\$conn = mysql_connect(DBHOST,DBUSER,DBPASS) or die('数据库连接错误');\nmysql_select_db(DBNAME) or die('数据库连接错误');\t\t//选择当前数据库\nmysql_query('set names gbk');\n?>";
51 # echo "<br />正在向数据库配置文件写入数据 <strong>../dbconnect.inc.php</strong> ";
52 # if(fwrite($fp,$configstr)) {
53 # echo "成功!";
54 # fclose($fp);
55 # } else {
56 # echo "失败!";
57 # fclose($fp);
58 # exit();
59 # }
60 # } else {
61 # echo "<br /><strong>数据库连接配置文件写入错误</strong> 你必须手动更改这个文件:<strong>../dbconnect.inc.php</strong>!";
62 # exit();
63 # }
64 #
65 #
66 # if(isset($_POST['demo'])) {
67 # echo "<br />创建测试数据";
68 # if($fdemo=fopen('data.sql','rb')) //装载演示数据
69 # {
70 # while (!feof($fdemo))
71 # {
72 # @mysql_query(fgets($fdemo)) or die(ErrorInfo());
73 # }
74 # echo "成功!";
75 # fclose($fdemo);
76 # }
77 # else //装载失败
78 # {
79 # echo "失败!";
80 # exit();
81 # }
82 # }
83 #
84 # echo "<br />锁定 install.php ";
85 # if(rename('install.php','install.php.lock')) {
86 # echo "成功!";
87 # } else {
88 # echo "失败!";
89 # }
90 #
91 # echo "<br />安装成功! 请将整个'install'目录删除!<br /><br /><a href='../index.php'>进入系统首页</a>";
92 # echo '</div>';
93 # } else {
94 # //echo "<br /><strong>安装程序终端</strong> 原因可能是: 您输入的某些数据有误或是数据库连接错误,请检查数据后重新安装";
95 # //exit();
96 # //}
97 #
98 # //if(!isset($_POST['install'])) {
99 # ?>
100 # <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transititonal.dtd">
101 # <html xmlns="http://www.w3.org/1999/xhtml">
102 # <head>
103 # <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
104 # <style>
105 # body{margin-left:20%;}
106 # #db{width:550px;background:#66CCFF;border:1px solid #000;padding:10px;text-indent:80px;}
107 # p{margin:1px;padding:4px;font-family:Arial;}
108 # </style>
109 # <title>个人多功能博客系统MySQL数据库自动安装程序</title>
110 # <script language="javascript">
111 # function chkform(oForm) {
112 # if(oForm.dbhost.value == "") {
113 # alert("请输入数据库服务器!");
114 # return false;
115 # }
116 # if(oForm.dbuser.value == "") {
117 # alert("请输入数据库用户名!");
118 # return false;
119 # }
120 # if(oForm.dbpass.value == "") {
121 # alert("请输入数据库密码!");
122 # return false;
123 # }
124 # if(oForm.dbname.value == "") {
125 # alert("请输入数据库名!");
126 # return false;
127 # }
128 #
129 # return confirm("确定安装名为"+oForm.dbname.value+"的数据库吗?");
130 # }
131 # </script>
132 # </head>
133 # <body>
134 # <h3>个人多功能博客系统MySQL数据库自动安装程序</h3>
135 # <div id="db">
136 # <form action="<?php echo $_SERVER['REQUEST_URI'];?>" method="post" onsubmit="return chkform(this)">
137 # <h4>数据库信息:</h4>
138 # <p>数据库的服务器: <input type="text" name="dbhost" id="dbhost" value="localhost" /> *</p>
139 # <p>数据库通信端口: <input type="text" name="dbport" id="dbport" />(一般情况不用填)</p>
140 # <p>数据库用户名称: <input type="text" name="dbuser" id="dbuser" value="root" /> *</p>
141 # <p>数据库用户密码: <input type="password" name="dbpass" id="dbpass" /> *</p>
142 # <p>[以上数据请从数据库管理员处获取]</p>
143 # <p>需创建的数据库: <input type="text" name="dbname" id="dbname" value="blog"/></p>
144 # <p><input type="checkbox" name="dropold" id="dropold" />删除同名旧数据库(不可恢复!)</p>
145 # <p><input type="checkbox" name="demo" id="demo" checked="checked"/>加载演示数据</p>
146 # <p align="center"><input type="submit" name="install" id="install" value="开始安装" /></p>
147 # </form>
148 # </div>
149 # </body>
150 # </html>
151 # <?php } ?>
2 #
3 # function ErrorInfo() {
4 # return "<ul style='font-family:Courier;font-size:11px;background:#FDF5E6;color:#696969;margin:3px;padding:10px;border:1px solid #696969;'>Notice!: System Error<li style='font-family:Courier;list-style-type:none'>ErrInfo: ".mysql_error()."</li><li style='font-family:Courier;list-style-type:none'>ErrCode: ".mysql_errno()."</li><li style='font-family:Courier;list-style-type:none'>ErrURIs: ".$_SERVER['REQUEST_URI']."</li></ul>";
5 # }
6 #
7 # if (isset($_POST['install'])) { //提交创建
8 # echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
9 # $dbserver = $_POST['dbhost'].(isset($_POST['dbport']) ? ":".$_POST['dbport']:
10 # '');
11 # $conn = @mysql_connect($dbserver, $_POST['dbuser'], $_POST['dbpass'])or die
12 # (ErrorInfo()); //连接到MySQL Server
13 # if (!$conn) die(ErrorInfo());
14 # @mysql_query('set names gbk');
15 #
16 # if (isset($_POST['dropold']))
17 # @mysql_query("DROP DATABASE IF EXISTS `".$_POST['dbname']."` ;")or die
18 # (ErrorInfo());
19 # //按条件删除原DB
20 # echo '<div style="margin-left:300px;">';
21 # echo"<br />创建数据库 ";
22 # @mysql_query("CREATE DATABASE IF NOT EXISTS `".$_POST['dbname'].
23 # "` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;")or die(ErrorInfo());
24 # //创建DB
25 # echo"OK!";
26 # $linktodb = @mysql_select_db($_POST['dbname'], $conn)or die(ErrorInfo());
27 # //打开数据库
28 # echo"<br />创建数据表 ";
29 # if ($ftable = file_get_contents("table.sql")) { //fopen('table.sql', 'r')) { //创建表
30 # //while (!feof($ftable)) {
31 # $ftables = explode(";",$ftable);
32 # for($i = 0;$i < count($ftables);$i++) {
33 # if($ftables[$i] == "") continue;
34 # @mysql_query($ftables[$i]) or die(ErrorInfo());
35 # //echo fgets($ftable)."<br>";
36 # //}
37 # //echo $i.$ftables[$i]."<br>";
38 # echo"成功!";
39 # //fclose($ftable);
40 # }
41 # } else { //不能创建表或者创建有误
42 # echo"失败!";
43 # echo"<br />删除原有数据库 ";
44 # @mysql_query("DROP DATABASE IF EXISTS ".$_POST['dbname']." ;")or die(ErrorInfo()); //删除所创建DB
45 # echo"OK!";
46 # exit();
47 # }
48 #
49 # if ($fp = fopen("../dbconnect.inc.php", 'w+')) {
50 # $configstr = "<?php\n//数据库信息\ndefine('DBHOST','".$dbserver."');\t\t//数据库服务器\ndefine('DBUSER','".$_POST['dbuser']."');\t\t\t\t//数据库用户\ndefine('DBPASS','".$_POST['dbpass']."');\t //数据库用户密码\ndefine('DBNAME','".$_POST['dbname']."');\t\t\t//数据库名称\n//连接到数据库\n\$conn = mysql_connect(DBHOST,DBUSER,DBPASS) or die('数据库连接错误');\nmysql_select_db(DBNAME) or die('数据库连接错误');\t\t//选择当前数据库\nmysql_query('set names gbk');\n?>";
51 # echo "<br />正在向数据库配置文件写入数据 <strong>../dbconnect.inc.php</strong> ";
52 # if(fwrite($fp,$configstr)) {
53 # echo "成功!";
54 # fclose($fp);
55 # } else {
56 # echo "失败!";
57 # fclose($fp);
58 # exit();
59 # }
60 # } else {
61 # echo "<br /><strong>数据库连接配置文件写入错误</strong> 你必须手动更改这个文件:<strong>../dbconnect.inc.php</strong>!";
62 # exit();
63 # }
64 #
65 #
66 # if(isset($_POST['demo'])) {
67 # echo "<br />创建测试数据";
68 # if($fdemo=fopen('data.sql','rb')) //装载演示数据
69 # {
70 # while (!feof($fdemo))
71 # {
72 # @mysql_query(fgets($fdemo)) or die(ErrorInfo());
73 # }
74 # echo "成功!";
75 # fclose($fdemo);
76 # }
77 # else //装载失败
78 # {
79 # echo "失败!";
80 # exit();
81 # }
82 # }
83 #
84 # echo "<br />锁定 install.php ";
85 # if(rename('install.php','install.php.lock')) {
86 # echo "成功!";
87 # } else {
88 # echo "失败!";
89 # }
90 #
91 # echo "<br />安装成功! 请将整个'install'目录删除!<br /><br /><a href='../index.php'>进入系统首页</a>";
92 # echo '</div>';
93 # } else {
94 # //echo "<br /><strong>安装程序终端</strong> 原因可能是: 您输入的某些数据有误或是数据库连接错误,请检查数据后重新安装";
95 # //exit();
96 # //}
97 #
98 # //if(!isset($_POST['install'])) {
99 # ?>
100 # <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transititonal.dtd">
101 # <html xmlns="http://www.w3.org/1999/xhtml">
102 # <head>
103 # <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
104 # <style>
105 # body{margin-left:20%;}
106 # #db{width:550px;background:#66CCFF;border:1px solid #000;padding:10px;text-indent:80px;}
107 # p{margin:1px;padding:4px;font-family:Arial;}
108 # </style>
109 # <title>个人多功能博客系统MySQL数据库自动安装程序</title>
110 # <script language="javascript">
111 # function chkform(oForm) {
112 # if(oForm.dbhost.value == "") {
113 # alert("请输入数据库服务器!");
114 # return false;
115 # }
116 # if(oForm.dbuser.value == "") {
117 # alert("请输入数据库用户名!");
118 # return false;
119 # }
120 # if(oForm.dbpass.value == "") {
121 # alert("请输入数据库密码!");
122 # return false;
123 # }
124 # if(oForm.dbname.value == "") {
125 # alert("请输入数据库名!");
126 # return false;
127 # }
128 #
129 # return confirm("确定安装名为"+oForm.dbname.value+"的数据库吗?");
130 # }
131 # </script>
132 # </head>
133 # <body>
134 # <h3>个人多功能博客系统MySQL数据库自动安装程序</h3>
135 # <div id="db">
136 # <form action="<?php echo $_SERVER['REQUEST_URI'];?>" method="post" onsubmit="return chkform(this)">
137 # <h4>数据库信息:</h4>
138 # <p>数据库的服务器: <input type="text" name="dbhost" id="dbhost" value="localhost" /> *</p>
139 # <p>数据库通信端口: <input type="text" name="dbport" id="dbport" />(一般情况不用填)</p>
140 # <p>数据库用户名称: <input type="text" name="dbuser" id="dbuser" value="root" /> *</p>
141 # <p>数据库用户密码: <input type="password" name="dbpass" id="dbpass" /> *</p>
142 # <p>[以上数据请从数据库管理员处获取]</p>
143 # <p>需创建的数据库: <input type="text" name="dbname" id="dbname" value="blog"/></p>
144 # <p><input type="checkbox" name="dropold" id="dropold" />删除同名旧数据库(不可恢复!)</p>
145 # <p><input type="checkbox" name="demo" id="demo" checked="checked"/>加载演示数据</p>
146 # <p align="center"><input type="submit" name="install" id="install" value="开始安装" /></p>
147 # </form>
148 # </div>
149 # </body>
150 # </html>
151 # <?php } ?>
table.sql 用于建表
1 # DROP TABLE IF EXISTS `admin`;
2 # CREATE TABLE IF NOT EXISTS `admin` (
3 # `id` smallint(6) NOT NULL auto_increment,
4 # `user` varchar(255) NOT NULL default '',
5 # `password` varchar(255) NOT NULL default '',
6 # PRIMARY KEY (`id`)
7 # ) TYPE=MyISAM COMMENT='管理员帐号密码';
8 # DROP TABLE IF EXISTS `article`;
9 # CREATE TABLE IF NOT EXISTS `article` (
10 # `id` int(11) NOT NULL auto_increment,
11 # `title` varchar(255) NOT NULL default '',
12 # `content` mediumtext NOT NULL,
13 # `pubtime` datetime NOT NULL default '0000-00-00 00:00:00',
14 # `category_id` int(10) NOT NULL default '0',
15 # `click` int(11) NOT NULL default '0',
16 # `num_comment` int(11) NOT NULL default '0',
17 # `tag` varchar(100) default NULL,
18 # `have_attachment` varchar(255) NOT NULL default '0',
19 # PRIMARY KEY (`id`)
20 # ) TYPE=MyISAM COMMENT='博客文章';
21 # DROP TABLE IF EXISTS `attachment`;
22 # CREATE TABLE IF NOT EXISTS `attachment` (
23 # `id` int(11) NOT NULL auto_increment,
24 # `click` int(11) NOT NULL default '0',
25 # `filename` varchar(255) NOT NULL default '',
26 # PRIMARY KEY (`id`)
27 # ) TYPE=MyISAM COMMENT='附件';
28 # DROP TABLE IF EXISTS `category`;
29 # CREATE TABLE IF NOT EXISTS `category` (
30 # `id` int(10) NOT NULL auto_increment,
31 # `name` varchar(50) NOT NULL default '',
32 # `alt` varchar(50) NOT NULL default '',
33 # PRIMARY KEY (`id`)
34 # ) TYPE=MyISAM COMMENT='文章分类';
35 # DROP TABLE IF EXISTS `comment`;
36 # CREATE TABLE IF NOT EXISTS `comment` (
37 # `id` int(11) NOT NULL auto_increment,
38 # `name` varchar(50) NOT NULL default '',
39 # `time` datetime NOT NULL default '0000-00-00 00:00:00',
40 # `content` mediumtext NOT NULL,
41 # `article_id` int(11) NOT NULL default '0',
42 # `url` varchar(200) default NULL,
43 # `exp` smallint(6) NOT NULL default '1',
44 # PRIMARY KEY (`id`)
45 # ) TYPE=MyISAM COMMENT='文章评论';
46 # DROP TABLE IF EXISTS `gbook`;
47 # CREATE TABLE IF NOT EXISTS `gbook` (
48 # `id` int(11) NOT NULL auto_increment,
49 # `name` varchar(50) NOT NULL default '',
50 # `time` datetime NOT NULL default '0000-00-00 00:00:00',
51 # `content` mediumtext NOT NULL,
52 # `url` varchar(200) NOT NULL default '',
53 # `exp` smallint(6) NOT NULL default '0',
54 # PRIMARY KEY (`id`)
55 # ) TYPE=MyISAM COMMENT='留言板';
56 # DROP TABLE IF EXISTS `link`;
57 # CREATE TABLE IF NOT EXISTS `link` (
58 # `id` int(11) NOT NULL auto_increment,
59 # `name` varchar(100) NOT NULL default '',
60 # `url` varchar(255) NOT NULL default '',
61 # `description` varchar(255) NOT NULL default '',
62 # `type` varchar(20) NOT NULL default '',
63 # PRIMARY KEY (`id`)
64 # ) TYPE=MyISAM COMMENT='友情链接';
65 # DROP TABLE IF EXISTS `mood`;
66 # CREATE TABLE IF NOT EXISTS `mood` (
67 # `id` smallint(6) NOT NULL auto_increment,
68 # `exp` smallint(6) NOT NULL default '0',
69 # `tip` varchar(255) NOT NULL default '',
70 # `exp_name` varchar(20) NOT NULL default '',
71 # PRIMARY KEY (`id`)
72 # ) TYPE=MyISAM COMMENT='最近心情';
73 # DROP TABLE IF EXISTS `video`;
74 # CREATE TABLE IF NOT EXISTS `video` (
75 # `id` int(11) NOT NULL auto_increment,
76 # `title` varchar(200) NOT NULL default '',
77 # `content` mediumtext NOT NULL,
78 # `pubtime` datetime NOT NULL default '0000-00-00 00:00:00',
79 # `click` int(11) NOT NULL default '0',
80 # `category_id` smallint(6) NOT NULL default '0',
81 # `star` smallint(6) NOT NULL default '0',
82 # `code` mediumtext NOT NULL,
83 # `num_comment` int(11) NOT NULL default '0',
84 # `vote_good` int(11) NOT NULL default '0',
85 # `vote_bad` int(11) NOT NULL default '0',
86 # PRIMARY KEY (`id`)
87 # ) TYPE=MyISAM COMMENT='博客视频';
88 # DROP TABLE IF EXISTS `video_cat`;
89 # CREATE TABLE IF NOT EXISTS `video_cat` (
90 # `id` smallint(6) NOT NULL auto_increment,
91 # `name` varchar(50) NOT NULL default '',
92 # `alt` varchar(50) NOT NULL default '',
93 # PRIMARY KEY (`id`)
94 # ) TYPE=MyISAM COMMENT='视频分类';
95 # DROP TABLE IF EXISTS `video_cmt`;
96 # CREATE TABLE IF NOT EXISTS `video_cmt` (
97 # `id` int(11) NOT NULL auto_increment,
98 # `name` varchar(50) NOT NULL default '',
99 # `time` datetime NOT NULL default '0000-00-00 00:00:00',
100 # `content` mediumtext NOT NULL,
101 # `video_id` int(11) NOT NULL default '0',
102 # `url` varchar(200) NOT NULL default '',
103 # `exp` smallint(6) NOT NULL default '0',
104 # PRIMARY KEY (`id`)
105 # ) TYPE=MyISAM COMMENT='视频评论';
2 # CREATE TABLE IF NOT EXISTS `admin` (
3 # `id` smallint(6) NOT NULL auto_increment,
4 # `user` varchar(255) NOT NULL default '',
5 # `password` varchar(255) NOT NULL default '',
6 # PRIMARY KEY (`id`)
7 # ) TYPE=MyISAM COMMENT='管理员帐号密码';
8 # DROP TABLE IF EXISTS `article`;
9 # CREATE TABLE IF NOT EXISTS `article` (
10 # `id` int(11) NOT NULL auto_increment,
11 # `title` varchar(255) NOT NULL default '',
12 # `content` mediumtext NOT NULL,
13 # `pubtime` datetime NOT NULL default '0000-00-00 00:00:00',
14 # `category_id` int(10) NOT NULL default '0',
15 # `click` int(11) NOT NULL default '0',
16 # `num_comment` int(11) NOT NULL default '0',
17 # `tag` varchar(100) default NULL,
18 # `have_attachment` varchar(255) NOT NULL default '0',
19 # PRIMARY KEY (`id`)
20 # ) TYPE=MyISAM COMMENT='博客文章';
21 # DROP TABLE IF EXISTS `attachment`;
22 # CREATE TABLE IF NOT EXISTS `attachment` (
23 # `id` int(11) NOT NULL auto_increment,
24 # `click` int(11) NOT NULL default '0',
25 # `filename` varchar(255) NOT NULL default '',
26 # PRIMARY KEY (`id`)
27 # ) TYPE=MyISAM COMMENT='附件';
28 # DROP TABLE IF EXISTS `category`;
29 # CREATE TABLE IF NOT EXISTS `category` (
30 # `id` int(10) NOT NULL auto_increment,
31 # `name` varchar(50) NOT NULL default '',
32 # `alt` varchar(50) NOT NULL default '',
33 # PRIMARY KEY (`id`)
34 # ) TYPE=MyISAM COMMENT='文章分类';
35 # DROP TABLE IF EXISTS `comment`;
36 # CREATE TABLE IF NOT EXISTS `comment` (
37 # `id` int(11) NOT NULL auto_increment,
38 # `name` varchar(50) NOT NULL default '',
39 # `time` datetime NOT NULL default '0000-00-00 00:00:00',
40 # `content` mediumtext NOT NULL,
41 # `article_id` int(11) NOT NULL default '0',
42 # `url` varchar(200) default NULL,
43 # `exp` smallint(6) NOT NULL default '1',
44 # PRIMARY KEY (`id`)
45 # ) TYPE=MyISAM COMMENT='文章评论';
46 # DROP TABLE IF EXISTS `gbook`;
47 # CREATE TABLE IF NOT EXISTS `gbook` (
48 # `id` int(11) NOT NULL auto_increment,
49 # `name` varchar(50) NOT NULL default '',
50 # `time` datetime NOT NULL default '0000-00-00 00:00:00',
51 # `content` mediumtext NOT NULL,
52 # `url` varchar(200) NOT NULL default '',
53 # `exp` smallint(6) NOT NULL default '0',
54 # PRIMARY KEY (`id`)
55 # ) TYPE=MyISAM COMMENT='留言板';
56 # DROP TABLE IF EXISTS `link`;
57 # CREATE TABLE IF NOT EXISTS `link` (
58 # `id` int(11) NOT NULL auto_increment,
59 # `name` varchar(100) NOT NULL default '',
60 # `url` varchar(255) NOT NULL default '',
61 # `description` varchar(255) NOT NULL default '',
62 # `type` varchar(20) NOT NULL default '',
63 # PRIMARY KEY (`id`)
64 # ) TYPE=MyISAM COMMENT='友情链接';
65 # DROP TABLE IF EXISTS `mood`;
66 # CREATE TABLE IF NOT EXISTS `mood` (
67 # `id` smallint(6) NOT NULL auto_increment,
68 # `exp` smallint(6) NOT NULL default '0',
69 # `tip` varchar(255) NOT NULL default '',
70 # `exp_name` varchar(20) NOT NULL default '',
71 # PRIMARY KEY (`id`)
72 # ) TYPE=MyISAM COMMENT='最近心情';
73 # DROP TABLE IF EXISTS `video`;
74 # CREATE TABLE IF NOT EXISTS `video` (
75 # `id` int(11) NOT NULL auto_increment,
76 # `title` varchar(200) NOT NULL default '',
77 # `content` mediumtext NOT NULL,
78 # `pubtime` datetime NOT NULL default '0000-00-00 00:00:00',
79 # `click` int(11) NOT NULL default '0',
80 # `category_id` smallint(6) NOT NULL default '0',
81 # `star` smallint(6) NOT NULL default '0',
82 # `code` mediumtext NOT NULL,
83 # `num_comment` int(11) NOT NULL default '0',
84 # `vote_good` int(11) NOT NULL default '0',
85 # `vote_bad` int(11) NOT NULL default '0',
86 # PRIMARY KEY (`id`)
87 # ) TYPE=MyISAM COMMENT='博客视频';
88 # DROP TABLE IF EXISTS `video_cat`;
89 # CREATE TABLE IF NOT EXISTS `video_cat` (
90 # `id` smallint(6) NOT NULL auto_increment,
91 # `name` varchar(50) NOT NULL default '',
92 # `alt` varchar(50) NOT NULL default '',
93 # PRIMARY KEY (`id`)
94 # ) TYPE=MyISAM COMMENT='视频分类';
95 # DROP TABLE IF EXISTS `video_cmt`;
96 # CREATE TABLE IF NOT EXISTS `video_cmt` (
97 # `id` int(11) NOT NULL auto_increment,
98 # `name` varchar(50) NOT NULL default '',
99 # `time` datetime NOT NULL default '0000-00-00 00:00:00',
100 # `content` mediumtext NOT NULL,
101 # `video_id` int(11) NOT NULL default '0',
102 # `url` varchar(200) NOT NULL default '',
103 # `exp` smallint(6) NOT NULL default '0',
104 # PRIMARY KEY (`id`)
105 # ) TYPE=MyISAM COMMENT='视频评论';
data.sql 用于存放演示数据
1 1. INSERT INTO `category` VALUES (1, 'Music', '音乐');
2 2. INSERT INTO `category` VALUES (2, 'Activity', '事件记录');
3 3. INSERT INTO `category` VALUES (3, 'Life', '生活');
4 4. INSERT INTO `category` VALUES (4, 'Site News', '站点新闻');
5 5. INSERT INTO `category` VALUES (5, 'Travel', '旅游记录');
6 6. INSERT INTO `category` VALUES (6, 'PHP', 'PHP技术');
7 7. INSERT INTO `category` VALUES (7, 'Web', 'Web技术');
8 8. INSERT INTO `category` VALUES (8, 'Works', '作业和作品');
9 9.
10 10. INSERT INTO `comment` VALUES (1, 'xx', '2007-08-14 22:10:30', '本博第一大留言抢先坐了..不谢不谢~~~<br />\r\n骗我和他们去倒垃圾然后带我去逛街…… 很搞笑啊..', 1, 'http://', 1);
11 11. INSERT INTO `comment` VALUES (2, 'HH姐', '2007-08-14 22:20:55', '超赞~~~~! 哈哈 打出这个词 才觉得 好词 一语双关嘛 哈哈 比上次那个成熟多了~ 进步青年!', 1, 'http://', 18);
12 12.
13 13. INSERT INTO `mood` (`id`,`exp`,`tip`,`exp_name`) VALUES (NULL,'3','今天来参加比赛','呵呵,紧张');
14
2 2. INSERT INTO `category` VALUES (2, 'Activity', '事件记录');
3 3. INSERT INTO `category` VALUES (3, 'Life', '生活');
4 4. INSERT INTO `category` VALUES (4, 'Site News', '站点新闻');
5 5. INSERT INTO `category` VALUES (5, 'Travel', '旅游记录');
6 6. INSERT INTO `category` VALUES (6, 'PHP', 'PHP技术');
7 7. INSERT INTO `category` VALUES (7, 'Web', 'Web技术');
8 8. INSERT INTO `category` VALUES (8, 'Works', '作业和作品');
9 9.
10 10. INSERT INTO `comment` VALUES (1, 'xx', '2007-08-14 22:10:30', '本博第一大留言抢先坐了..不谢不谢~~~<br />\r\n骗我和他们去倒垃圾然后带我去逛街…… 很搞笑啊..', 1, 'http://', 1);
11 11. INSERT INTO `comment` VALUES (2, 'HH姐', '2007-08-14 22:20:55', '超赞~~~~! 哈哈 打出这个词 才觉得 好词 一语双关嘛 哈哈 比上次那个成熟多了~ 进步青年!', 1, 'http://', 18);
12 12.
13 13. INSERT INTO `mood` (`id`,`exp`,`tip`,`exp_name`) VALUES (NULL,'3','今天来参加比赛','呵呵,紧张');
14
保存好这3个文件安装程序就可以运行了,只要执行一下install.php就可以完成新建数据库,插入表,插入数据等工作,十分方便,而在运行完安装程序后应该提示用户删除install.php,以免重复安装