forked from ajaximrpg/AjaxIM341
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.php
More file actions
237 lines (209 loc) · 10.9 KB
/
Copy pathinstall.php
File metadata and controls
237 lines (209 loc) · 10.9 KB
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
<?php
///////////////////////////////////
// ajax im 3.41 //
// AJAX Instant Messenger //
// Copyright (c) 2006-2008 //
// http://www.ajaxim.com/ //
// Do not remove this notice //
///////////////////////////////////
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>ajax im - installation</title>
<style type="text/css" media="screen">
body {
background: #101010;
}
a {
color: #fff;
}
h1 {
font: 160px Arial, Verdana, Tahoma, sans-serif;
color: #fff;
margin: 0 auto 40px;
padding: 0;
text-align: center;
width: 80%;
}
h2 {
font: 28px tahoma, verdana, arial, sans-serif;
font-weight: bold;
color: #84e03a;
margin: 0;
padding: 0 0 10px 0;
}
div {
border: 2px solid #1d1d1d;
padding: 10px;
font: 12px Verdana, Tahoma, Arial, sans-serif;
width: 400px;
margin: 10px auto;
color: #fff;
}
label, input {
font: 14px Verdana, Tahoma, Arial, sans-serif;
}
label {
display: block;
width: 100px;
float: left;
color: #fff;
}
input {
border: 0;
padding: 2px;
}
input#install {
display: block;
background-color: #101010;
color: #84e03a;
font: 32px Verdana, Tahoma, Arial, sans-serif;
margin: 0 auto;
text-decoration: underline;
}
input#username, input#password, input#email, label {
margin-top: 10px;
}
input#username {
clear: right;
}
div.error {
color: #ff0000;
text-align: center;
}
div.success {
color: #84e03a;
text-align: center;
}
</style>
</head>
<body>
<h1>ajax im</h1>
<?php
if(!$_GET['go']) {
?>
<div>
<h2>before you begin...</h2>
Did you remember to:
<ul>
<li>setup a database for ajax im?</li>
<li>edit <strong>config.php</strong> to match your MySQL configuration?</li>
<?php if ($maxBuddyIconSize > 0 && trim(substr(sprintf('%o', fileperms('./buddyicons/')), -4)) != 777) { echo '<li>CHMOD <strong>buddyicons/</strong> to 0777, it is at: '. substr(sprintf('%o', fileperms('./buddyicons/')), -4) .'?</li>'; } ?>
</ul>
</div>
<form method="post" action="install.php?go=true">
<div>
<h2>first admin account</h2>
This will be the first account registered on ajax im. It will automatically be set to be an admin account.
<label id="username-label" for="username">username:</label> <input type="text" name="username" id="username" />
<label id="password-label" for="password">password:</label> <input type="password" name="password" id="password" />
<label id="email-label" for="password">email:</label> <input type="text" name="email" id="email" />
</div>
<div>
<h2>ready?</h2>
<input type="submit" id="install" value="install!" />
</div>
</form>
<?php
} else {
?>
<div>
<h2>installing...</h2>
<?php
require 'config.php';
$link = mysql_connect($sql_host, $sql_user, $sql_pass);
mysql_select_db($sql_db);
$table_messages = 'CREATE TABLE `'.SQL_PREFIX.'messages` ( `recipient` text, `sender` text, `message` text, `type` text, `stamp` text, `id` bigint(20) unsigned NOT NULL auto_increment, UNIQUE KEY `id` (`id`) ) ;';
if(!mysql_query($table_messages)) {
if(mysql_errno() == 1050) {
print "Table '".SQL_PREFIX."messages' already exists! If you had a version of ajax im less than 3.2 installed on this database, please delete the table and then run this script again, otherwise ignore this error.<br /><br />\n";
$problem = true;
} else {
print("<b>A MySQL error occured:</b> (" . mysql_errno() . ") " . mysql_error() . "<br /><br />\n");
$error = true;
}
} else {
mysql_query('ALTER TABLE `'.SQL_PREFIX.'messages` CHANGE `message` `message` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL');
print "Table '".SQL_PREFIX."messages' added successfully!<br /><br />\n";
}
$table_users = 'CREATE TABLE `'.SQL_PREFIX.'users` ( `username` varchar(32), `password` varchar(32), `email` text, `is_online` int(11) default \'0\', `last_ping` text, `last_ip` varchar(15), `banned` tinyint(1) default \'0\', `admin` tinyint(1) default \'0\', `buddyicon` varchar(4) NOT NULL default \'none\', `profile` text, `id` bigint(20) unsigned NOT NULL auto_increment, UNIQUE KEY `id` (`id`), UNIQUE `username` (`username`) ) ;';
if(!mysql_query($table_users)) {
if(mysql_errno() == 1050) {
print "Table '".SQL_PREFIX."users' already exists! If you had a version of ajax im less than 3.2 installed on this database, please delete the table and then run this script again, otherwise ignore this error.<br /><br />\n";
} else {
print("<b>A MySQL error occured:</b> (" . mysql_errno() . ") " . mysql_error() . "<br /><br />\n");
$error = true;
}
} else {
print "Table '".SQL_PREFIX."users' added successfully!<br /><br />\n";
}
$table_chats = 'CREATE TABLE `'.SQL_PREFIX.'chats` ( `room` text, `user` text, `id` bigint(20) unsigned NOT NULL auto_increment, UNIQUE KEY `id` (`id`) ) ;';
if(!mysql_query($table_chats)) {
if(mysql_errno() == 1050) {
print "Table '".SQL_PREFIX."chats' already exists! If you had a version of ajax im less than 3.0 installed on this database, please delete the table and then run this script again, otherwise ignore this error.<br /><br />\n";
$problem = true;
} else {
print("<b>A MySQL error occured:</b> (" . mysql_errno() . ") " . mysql_error() . "<br /><br />\n");
$error = true;
}
} else {
mysql_query('ALTER TABLE `'.SQL_PREFIX.'chats` CHANGE `room` `room` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL');
print "Table '".SQL_PREFIX."chats' added successfully!<br /><br />\n";
}
$table_buddylists = 'CREATE TABLE `'.SQL_PREFIX.'buddylists` (`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `user` VARCHAR( 100 ) NOT NULL, `buddy` VARCHAR( 100 ) NOT NULL, `group` VARCHAR( 100 ) NOT NULL, INDEX ( `user` , `group` )) ENGINE = MYISAM ;';
if(!mysql_query($table_buddylists)) {
if(mysql_errno() == 1050) {
print "Table '".SQL_PREFIX."buddylists' already exists! If you had a version of ajax im less than 3.2 installed on this database, please delete the table and then run this script again, otherwise ignore this error.<br /><br />\n";
$problem = true;
} else {
print("<b>A MySQL error occured:</b> (" . mysql_errno() . ") " . mysql_error() . "<br /><br />\n");
$error = true;
}
} else {
print "Table '".SQL_PREFIX."buddylists' added successfully!<br /><br />\n";
}
$table_blocklists = 'CREATE TABLE `'.SQL_PREFIX.'blocklists` (`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `user` VARCHAR( 100 ) NOT NULL, `buddy` VARCHAR( 100 ) NOT NULL, INDEX ( `user` , `buddy` )) ENGINE = MYISAM ;';
if(!mysql_query($table_blocklists)) {
if(mysql_errno() == 1050) {
print "Table '".SQL_PREFIX."blocklists' already exists! If you had a version of ajax im less than 3.2 installed on this database, please delete the table and then run this script again, otherwise ignore this error.<br /><br />\n";
$problem = true;
} else {
print("<b>A MySQL error occured:</b> (" . mysql_errno() . ") " . mysql_error() . "<br /><br />\n");
$error = true;
}
} else {
print "Table '".SQL_PREFIX."blocklists' added successfully!<br /><br />\n";
}
$add_user = 'INSERT INTO `'.SQL_PREFIX.'users` (username, password, email, admin) VALUES (\'' . mysql_real_escape_string($_POST['username']) . '\', \'' . mysql_real_escape_string(md5($_POST['password'])) . '\', \'' . mysql_real_escape_string($_POST['email']) . '\', 1)';
if(!mysql_query($add_user)) {
print("<b>A MySQL error occured:</b> (" . mysql_errno() . ") " . mysql_error() . "<br /><br />\n");
print "Unable to add the first user! This likely means there was some other issue during installation.<br /><br />\n";
$error = true;
} else {
print "First/admin user registered!<br /><br />\n";
}
if ($maxBuddyIconSize > 0) {
if (trim(substr(sprintf('%o', fileperms('./buddyicons/')), -4)) != 777) {
$error = true;
print "<b>File permissions:</b>: <br/><br/>CHMOD buddyicons/ to 0777</b><br/><br/>";
} else {
print "You have change permissions of buddyicons/<br/><br/>";
}
}
mysql_close();
?>
</div>
<div class="<?php if($error) print 'error'; else print 'success'; ?>">
<h2>status</h2>
<?php
if($error)
print 'There was an error while installing the script! Please refer to the messages above to solve your issue.';
else
print 'Congratulations! ajax im installed successfully! You can now login with your new admin account <a href="./">here</a>. Please be sure to delete install.php and update.php!';
?>
</div>
<?php } ?>
</body>
</html>