-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.php
executable file
·251 lines (177 loc) · 8.65 KB
/
setup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<?php
/********************************************************
*
* phpAbstracts
* http://www.phpabstracts.com
*
* For copyright and license information, see readme.txt
*
*********************************************************/
// If form was submitted
if ($_POST['DBHost'])
{
//If admin variables were submitted
if ($_POST['admin_user'] && $_POST['admin_email'] && $_POST['admin_pass'])
{
// Check that their config file is writable
if(is_writable('db.php'))
{
// Test the connection
if(@mysql_connect($_POST['DBHost'], $_POST['DBUser'], $_POST['DBPass']))
{
if(@mysql_select_db($_POST['DBName']))
{
$status = "Success";
// Content that will be written to the config file
$content = "<?php\n";
$content.= "\$host = '".addslashes($_POST['DBHost'])."';\n";
$content.= "\$database = '".addslashes($_POST['DBName'])."';\n";
$content.= "\$username = '".addslashes($_POST['DBUser'])."';\n";
$content.= "\$password = '".addslashes($_POST['DBPass'])."';\n";
$content.= "\n";
$content.= "?>";
// Open the includes/config.php for writting
$handle = fopen('db.php', 'w');
// Write the config file
fwrite($handle, $content);
// Close the file
fclose($handle);
mysql_query("CREATE TABLE `abstracts` (
`abstract_id` int(11) NOT NULL auto_increment,
`date` varchar(40) NOT NULL default '',
`name` varchar(100) NOT NULL default 'none',
`clinic` varchar(100) NOT NULL default 'none',
`address` varchar(100) NOT NULL default 'none',
`city` varchar(100) NOT NULL default 'none',
`state` char(2) NOT NULL default '',
`zip` varchar(10) NOT NULL default 'none',
`email` varchar(60) NOT NULL default 'none',
`phone` varchar(30) NOT NULL default 'none',
`title` varchar(255) NOT NULL default 'none',
`length` varchar(20) NOT NULL default 'none',
`summary` text NOT NULL,
`gap` text NOT NULL,
`need` text NOT NULL,
`change` text NOT NULL,
`presentation` varchar(80) NOT NULL default 'none',
`disclosure` varchar(80) NOT NULL default 'none',
`word_count` int(3) NOT NULL default '0',
`master_status` varchar(40) NOT NULL default 'Unfiled',
`scholarship` varchar(20) NOT NULL,
`last_edit` varchar(50) NOT NULL,
PRIMARY KEY (`abstract_id`)
)
ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1418 ;");
mysql_query("CREATE TABLE `reviews` ( `review_id` int(11) NOT NULL auto_increment, `abstract_id` int(11) NOT NULL default '0', `user_id` int(11) NOT NULL default '0', `status` varchar(20) NOT NULL, `relevance` varchar(15) NOT NULL default '0', `quality` varchar(15) NOT NULL default '0', `comments` text NOT NULL, `recommendation` varchar(25) NOT NULL, PRIMARY KEY (`review_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=749 ;");
mysql_query("CREATE TABLE `users` ( `user_id` int(11) NOT NULL auto_increment, `login` varchar(40) NOT NULL default '', `password` varchar(40) NOT NULL default '', `name` varchar(75) NOT NULL default '', `email` varchar(40) NOT NULL default '', `role` varchar(10) NOT NULL default '', PRIMARY KEY (`user_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=62 ;");
mysql_query("CREATE TABLE `disclosure` (
`disclosure_id` int(11) NOT NULL auto_increment,
`activity` varchar(100) NOT NULL default '',
`activity_date` varchar(40) NOT NULL default '',
`activity_role` varchar(90) NOT NULL default '',
`interest` int(1) NOT NULL default '',
`commercial_prod` int(1) NOT NULL default '',
`signature` varchar(80) NOT NULL default '',
`sig_date` varchar(40) NOT NULL default ''
PRIMARY KEY (`disclosure_id`)
)
ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
mysql_query("CREATE TABLE `interest` (
`interest_id` int(11) NOT NULL auto_increment,
`disclosure_id` int(11) NOT NULL,
`interest` varchar(100) NOT NULL default '',
`compensation` varchar(100) NOT NULL default '',
`role` text NOT NULL default '',
PRIMARY KEY (`interest_id`)
FOREIGN KEY (disclosure_id) REFERENCES disclosure (disclosure_id)
)
ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
mysql_query("CREATE TABLE `commercial_product` (
`commercial_prod_id` int(11) NOT NULL auto_increment,
`disclosure_id` int(11) NOT NULL,
`product` varchar(120) NOT NULL default '',
`description` text NOT NULL default '',
PRIMARY KEY (`commerical_prod_id`)
FOREIGN KEY (disclosure_id) REFERENCES disclosure (disclosure_id)
)
ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
mysql_query("INSERT INTO `users` VALUES (1, '".addslashes($_POST['admin_user'])."', '" .
addslashes($_POST['admin_pass']) . "', 'Administrator', '" .
addslashes($_POST['admin_email']) . "', 'ADMIN');");
$status = "Complete!";
}//dbname
else
$status = "This database does not exist.";
}//dbhost etc
else
$status = "Connection failed.";
}//writable
else
$status = "The file db.php is not writable.";
}//If admin variables
else
$status = "Please enter an admin user";
}//If form was submitted
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo $site_title; ?></title>
<link href="css/abstracts.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="header" class="top_container">
<img src="<?php echo $site_logo ?>">
</div>
<div class="centering_container" id="main_container" >
<div class="leftcol">
<h1>Setup</h1>
<?
if ($status)
echo "<div class='status'>" . $status . "</div>";
if ($status == "Complete!") {
echo "<p>Your system is now properly setup. You may <a href='login.php'>login</a> to begin using it.</p>";
}
else {
?>
<p style="width:420px;">Please fill in your database connection variables below.</p>
<form method="post" action="setup.php" class="aform">
<label for "DBHost">Database Host</label>
<input type="text" id="DBHost" name="DBHost" size="30" /><br />
<label for "DBUser">Database Username</label>
<input type="text" id="DBUser" name="DBUser" size="30" /><br />
<label for "DBPass">Database Password</label>
<input type="text" id="DBPass" name="DBPass" size="30" /><br />
<p style="width:420px;">Type in the name of your database (this must already exist).</p>
<label for "DBName">Database Name</label>
<input type="text" id="DBName" name="DBName" size="30" /><br />
<p style="width:420px;">You must also create an master admin user.<br />Please enter this information below, and save for your records.</p>
<label for "admin_user">Admin User</label>
<input type="text" id="admin_user" name="admin_user" size="30" /><br />
<label for "admin_pass">Admin Password</label>
<input type="text" id="admin_pass" name="admin_pass" size="30" /><br />
<label for "admin_email">Admin Email</label>
<input type="text" id="admin_email" name="admin_email" size="30" /><br />
<br /><br />
<label> </label>
<input type="submit" value="Submit" />
</form>
<?php
}//end else
?>
</div>
<div class="rightcol">
<h2>Initial Setup</h2>
<p>Welcome to phpAbstracts.</p>
<p>Using this form, you will be able to automatically setup your database
for use with this system.</p>
<p style="font-weight:bold;">Before you begin</p>
<p>You must manually create an empty database before you run this script!</p>
<p> Please create an empty database
(for example: through your web host or by using phpMyAdmin), and then then type in the name of the database where specified.</p>
</div>
<div class="breaker"> </div>
</div>
<div class="footer" style="margin-top:10px;">Powered by <a href="http://www.phpabstracts.com">phpAbstracts</a>, licensed under the GNU GPL.</div>
</body>
</html>