forked from heyman/mms-decoder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.php
130 lines (115 loc) · 3.93 KB
/
install.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
<?php
/**
* Copyright (C) 2004 Jonatan Heyman
*
* This file is part of MMS Decoder Example Application.
* Recieve an MMS from the client.
*
* MMS Decoder is free software; you can redistribute it and/or
* modify it under the terms of the Affero General Public License as
* published by Affero, Inc.; either version 1 of the License, or
* (at your option) any later version.
*
* MMS Decoder is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Affero General Public License for more details.
*
* You should have received a copy of the Affero General Public
* License in the COPYING file that comes with The Affero Project; if
* not, write to Affero, Inc., 510 Third Street, Suite 225, San
* Francisco, CA 94107 USA.
*/
if (isset($_POST['create'])) {
// connect to the database
if (!mysql_connect($_POST['host'], $_POST['user'], $_POST['pass']))
die("Could not connct to database, check host/user/pass settings!");
// check if we shall create a new database
if ($_POST['create'] == "create") {
if (!function_exists("mysql_create_db"))
die("The mysql_create_db() function does not exist in your PHP installation! Please create the database by hand, and chose the 'Use existing DB' option in the installation script.");
if (!mysql_create_db($_POST['name']))
die("Database could not be created: " . $_POST['name']);
}
// select database
if (!mysql_select_db($_POST['name']))
die("Could not select db: " . $_POST['name']);
/* mms table */
$sql =
CREATE TABLE `mms` (
`id` int(10) NOT NULL auto_increment,
`from` char(255) NOT NULL default '',
`to` char(255) NOT NULL default '',
`subject` char(255) NOT NULL default '',
`content_type` char(255) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=28 ;
";
if (!mysql_query($sql))
print("Could not create table: mms. MySQL: " . mysql_error() . "<br>\n");
/* parts table */
$sql =
CREATE TABLE `parts` (
`id` int(10) NOT NULL auto_increment,
`mmsid` int(10) NOT NULL default '0',
`datalen` int(12) NOT NULL default '0',
`content_type` varchar(255) NOT NULL default '',
`data` mediumblob NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=33 ;
";
if (!mysql_query($sql))
print("Could not create table: parts. MySQL: " . mysql_error() . "<br>\n");
echo
Installation complete!<br><br>
Please set the right configuration in the config.php file to get the application to work. <br>
I recommend that you remove the install.php from any direcory where it is accessible over
over HTTP without a password.
";
} else {
?>
<html>
<head>
<title>MMS Decoder Example Application installation script</title>
</head>
<body>
This is an installation script for the MMS Decoder Example application. The purpose of this script
is to save people the hassle to create the database/tables by hand. <br>
See the readme file of the example application, for a more detailed description on how to install the application.
<br><br>
<form action="install.php" method="POST">
<table border="0">
<tr>
<td>MySQL host</td>
<td><input type="text" name="host"></td>
</tr>
<tr>
<td>MySQL username</td>
<td><input type="text" name="user"></td>
</tr>
<tr>
<td>MySQL password</td>
<td><input type="password" name="pass"></td>
</tr>
<tr>
<td>Database name</td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td>Create DB or use existing?</td>
<td>
<select name="create">
<option value="create" selected>Create DB</option>
<option value="existing">Use existing DB</option>
</select>
</td>
</tr>
</table>
<br><br>
<input type="submit" value="Create database/tables">
</form>
</body>
</html>
<?php
}
?>