geen chmod naar 777
Code (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
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
<?php
#==== test values ====#
if ($Submit) {
$message ="";
if (!$dbuser || !$dbdb || !dbserver || !$adminuser || !$adminpass || !$adminmail) {
$message = "<br>Error : Something is missing...";
}
if ($adminpass != $adminpassbis) {
$message = $message."<br>Error : Check Administrator Passwords...";
}
}
else {
$message ="Please fill the form...";
}
#===== test if the file exist =====#
if( file_exists( 'inc/configuration.php')) {
$message = "<br>Error : Config file already on your server...";
}
#==== test connection ====#
if (!$message) {
$db = mysql_connect($dbserver, $dbuser, $dbpass);
if (!$db) {
$message = "<br>Error : no connection to server, check parameters...";
}
if (!$message && !mysql_select_db($dbdb, $db)) {
$message = "<br>Error : no database $dbdb on your server...";
}
}
if (!$message) {
echo
#==== create the config file ====#
$file = fopen("inc/configuration.php","a+");
fwrite($file,"<?php\r");
fwrite($file,"#====== 1xs ======#\r");
fwrite($file,"# http://www.1xs.net #\r");
fwrite($file,"#========================#\r");
fwrite($file,"define (\"CMS_VERSION\", \"62\");\r");
fwrite($file,"define (\"DB_USER\", \"$dbuser\");\r");
fwrite($file,"define (\"DB_PASS\", \"$dbpass\");\r");
fwrite($file,"define (\"DB_SERVER\", \"$dbserver\");\r");
fwrite($file,"define (\"DB_DATABASE\", \"$dbdb\");\r");
fwrite($file,"define (\"DB_PREFIX\", \"$dbprefix\");\r");
fwrite($file,"define (\"ADMIN_USER\", \"$adminuser\");\r");
fwrite($file,"define (\"ADMIN_PASS\", \"$adminpass\");\r");
fwrite($file,"define (\"ADMIN_MAIL\", \"$adminmail\");\r");
fwrite($file,"?>");
fclose($file);
#==== sql scripts ====#
include_once 'inc/configuration.php';
include_once 'inc/db.php';
$db = new DB();
$req = "
CREATE TABLE `".$dbprefix."_stats` (
time date default NULL,
pageId int(20) NOT NULL default '0',
clientIp varchar(12) NOT NULL default '',
referer varchar(250) NOT NULL default '',
KEY time (time)
)
";
$db->query($req);
$req = "
CREATE TABLE `".$dbprefix."_comments` (
id int(20) NOT NULL auto_increment,
pageId int(20) NOT NULL default '0',
comment text NOT NULL,
userName varchar(150) default NULL,
userEmail varchar(150) default NULL,
date datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (id)
)
";
$db->query($req);
$req = "
CREATE TABLE `".$dbprefix."_config` (
id tinyint(1) NOT NULL default '1',
version varchar(15) NOT NULL default 'none',
name varchar(250) default NULL,
description varchar(250) default NULL,
keywords varchar(250) default NULL,
url varchar(250) NOT NULL default 'http://www.yoursite.net/yourfolder',
mail enum('on','off') NOT NULL default 'on',
language varchar(250) NOT NULL default 'english',
cache enum('on','off') NOT NULL default 'off',
cacheDelay int(11) NOT NULL default '600',
news enum('on','off') NOT NULL default 'on',
stats enum('on','off') NOT NULL default 'on',
PRIMARY KEY (id)
)
";
$db->query($req);
$req = "
INSERT INTO ".$dbprefix."_config VALUES (1, '2.2', 'Name of your site', 'Short description',
'dixit, internet, do it yourself', 'http://www.yoursite.net/yourfolder', 'on', 'english',
'off', 0, 'on', 'on')
";
$db->query($req);
$req = "
CREATE TABLE `".$dbprefix."_newsletter` (
`id` int(20) NOT NULL auto_increment,
`email` varchar(250) NOT NULL default '',
`registrationDate` datetime NOT NULL default '0000-00-00 00:00:00',
KEY `news_id` (`id`)
)
";
$db->query($req);
$req = "
CREATE TABLE `".$dbprefix."_pages` (
id int(20) NOT NULL auto_increment,
title varchar(255) NOT NULL default '',
content text,
topicId int(20) NOT NULL default '0',
startDate date default NULL,
userId int(20) default NULL,
template varchar(200) NOT NULL default 'dixit.tmpl.php',
status varchar(50) NOT NULL default 'topic',
position varchar(4) NOT NULL default '0',
PRIMARY KEY (id),
UNIQUE KEY id (id)
)
";
$db->query($req);
$req = "
INSERT INTO `".$dbprefix."_pages` VALUES (1, 'home', '<b>Welcome !</>', 0, NULL, 0,
'dixit.tmpl.php', 'topic', '0')
";
$db->query($req);
$req = "
CREATE TABLE `".$dbprefix."_users` (
id int(20) NOT NULL auto_increment,
name varchar(200) default NULL,
password varchar(200) default NULL,
email varchar(200) default NULL,
adminTopic int(20) NOT NULL default '0',
rights varchar(20) NOT NULL default 'admin',
lastActivity datetime NOT NULL default '0000-00-00 00:00:00',
lastIp varchar(20) NOT NULL default '',
PRIMARY KEY (id),
UNIQUE KEY usr_id (id)
)
";
$db->query($req);
$db->close();
// user message
$content = "<b>Installation finished</b><br>";
$content = $content."You can now access to the administration panel (click <a
href=\"admin.php\">here</a>)";
}
else {
$content = "
<form name=\"form\" method=\"post\" action=\"\">
Database Server : <input type=\"text\" name=\"dbserver\" value=\"$dbserver\"> ex :
localhost<br>
Database Name : <input type=\"text\" name=\"dbdb\" value=\"$dbdb\"> usually your
username...<br>
Database Username : <input type=\"text\" name=\"dbuser\" value=\"$dbuser\"> <br>
Database Password : <input type=\"text\" name=\"dbpass\" value=\"$dbpass\"><br>
Database Prefix : <input type=\"text\" name=\"dbprefix\" value=\"$dbprefix\"> anything like
1xs...<br>
<br>
Administrator Username : <input type=\"text\" name=\"adminuser\" value=\"$adminuser\"><br>
Administrator E-mail : <input type=\"text\" name=\"adminmail\" value=\"$adminmail\"><br>
Administrator Password : <input type=\"password\" name=\"adminpass\"><br>
Administrator Password (again) : <input type=\"password\" name=\"adminpassbis\"><br>
<br>
<input type=\"submit\" name=\"Submit\" value=\"Install\">
</form>";
}
?>
#==== test values ====#
if ($Submit) {
$message ="";
if (!$dbuser || !$dbdb || !dbserver || !$adminuser || !$adminpass || !$adminmail) {
$message = "<br>Error : Something is missing...";
}
if ($adminpass != $adminpassbis) {
$message = $message."<br>Error : Check Administrator Passwords...";
}
}
else {
$message ="Please fill the form...";
}
#===== test if the file exist =====#
if( file_exists( 'inc/configuration.php')) {
$message = "<br>Error : Config file already on your server...";
}
#==== test connection ====#
if (!$message) {
$db = mysql_connect($dbserver, $dbuser, $dbpass);
if (!$db) {
$message = "<br>Error : no connection to server, check parameters...";
}
if (!$message && !mysql_select_db($dbdb, $db)) {
$message = "<br>Error : no database $dbdb on your server...";
}
}
if (!$message) {
echo
#==== create the config file ====#
$file = fopen("inc/configuration.php","a+");
fwrite($file,"<?php\r");
fwrite($file,"#====== 1xs ======#\r");
fwrite($file,"# http://www.1xs.net #\r");
fwrite($file,"#========================#\r");
fwrite($file,"define (\"CMS_VERSION\", \"62\");\r");
fwrite($file,"define (\"DB_USER\", \"$dbuser\");\r");
fwrite($file,"define (\"DB_PASS\", \"$dbpass\");\r");
fwrite($file,"define (\"DB_SERVER\", \"$dbserver\");\r");
fwrite($file,"define (\"DB_DATABASE\", \"$dbdb\");\r");
fwrite($file,"define (\"DB_PREFIX\", \"$dbprefix\");\r");
fwrite($file,"define (\"ADMIN_USER\", \"$adminuser\");\r");
fwrite($file,"define (\"ADMIN_PASS\", \"$adminpass\");\r");
fwrite($file,"define (\"ADMIN_MAIL\", \"$adminmail\");\r");
fwrite($file,"?>");
fclose($file);
#==== sql scripts ====#
include_once 'inc/configuration.php';
include_once 'inc/db.php';
$db = new DB();
$req = "
CREATE TABLE `".$dbprefix."_stats` (
time date default NULL,
pageId int(20) NOT NULL default '0',
clientIp varchar(12) NOT NULL default '',
referer varchar(250) NOT NULL default '',
KEY time (time)
)
";
$db->query($req);
$req = "
CREATE TABLE `".$dbprefix."_comments` (
id int(20) NOT NULL auto_increment,
pageId int(20) NOT NULL default '0',
comment text NOT NULL,
userName varchar(150) default NULL,
userEmail varchar(150) default NULL,
date datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (id)
)
";
$db->query($req);
$req = "
CREATE TABLE `".$dbprefix."_config` (
id tinyint(1) NOT NULL default '1',
version varchar(15) NOT NULL default 'none',
name varchar(250) default NULL,
description varchar(250) default NULL,
keywords varchar(250) default NULL,
url varchar(250) NOT NULL default 'http://www.yoursite.net/yourfolder',
mail enum('on','off') NOT NULL default 'on',
language varchar(250) NOT NULL default 'english',
cache enum('on','off') NOT NULL default 'off',
cacheDelay int(11) NOT NULL default '600',
news enum('on','off') NOT NULL default 'on',
stats enum('on','off') NOT NULL default 'on',
PRIMARY KEY (id)
)
";
$db->query($req);
$req = "
INSERT INTO ".$dbprefix."_config VALUES (1, '2.2', 'Name of your site', 'Short description',
'dixit, internet, do it yourself', 'http://www.yoursite.net/yourfolder', 'on', 'english',
'off', 0, 'on', 'on')
";
$db->query($req);
$req = "
CREATE TABLE `".$dbprefix."_newsletter` (
`id` int(20) NOT NULL auto_increment,
`email` varchar(250) NOT NULL default '',
`registrationDate` datetime NOT NULL default '0000-00-00 00:00:00',
KEY `news_id` (`id`)
)
";
$db->query($req);
$req = "
CREATE TABLE `".$dbprefix."_pages` (
id int(20) NOT NULL auto_increment,
title varchar(255) NOT NULL default '',
content text,
topicId int(20) NOT NULL default '0',
startDate date default NULL,
userId int(20) default NULL,
template varchar(200) NOT NULL default 'dixit.tmpl.php',
status varchar(50) NOT NULL default 'topic',
position varchar(4) NOT NULL default '0',
PRIMARY KEY (id),
UNIQUE KEY id (id)
)
";
$db->query($req);
$req = "
INSERT INTO `".$dbprefix."_pages` VALUES (1, 'home', '<b>Welcome !</>', 0, NULL, 0,
'dixit.tmpl.php', 'topic', '0')
";
$db->query($req);
$req = "
CREATE TABLE `".$dbprefix."_users` (
id int(20) NOT NULL auto_increment,
name varchar(200) default NULL,
password varchar(200) default NULL,
email varchar(200) default NULL,
adminTopic int(20) NOT NULL default '0',
rights varchar(20) NOT NULL default 'admin',
lastActivity datetime NOT NULL default '0000-00-00 00:00:00',
lastIp varchar(20) NOT NULL default '',
PRIMARY KEY (id),
UNIQUE KEY usr_id (id)
)
";
$db->query($req);
$db->close();
// user message
$content = "<b>Installation finished</b><br>";
$content = $content."You can now access to the administration panel (click <a
href=\"admin.php\">here</a>)";
}
else {
$content = "
<form name=\"form\" method=\"post\" action=\"\">
Database Server : <input type=\"text\" name=\"dbserver\" value=\"$dbserver\"> ex :
localhost<br>
Database Name : <input type=\"text\" name=\"dbdb\" value=\"$dbdb\"> usually your
username...<br>
Database Username : <input type=\"text\" name=\"dbuser\" value=\"$dbuser\"> <br>
Database Password : <input type=\"text\" name=\"dbpass\" value=\"$dbpass\"><br>
Database Prefix : <input type=\"text\" name=\"dbprefix\" value=\"$dbprefix\"> anything like
1xs...<br>
<br>
Administrator Username : <input type=\"text\" name=\"adminuser\" value=\"$adminuser\"><br>
Administrator E-mail : <input type=\"text\" name=\"adminmail\" value=\"$adminmail\"><br>
Administrator Password : <input type=\"password\" name=\"adminpass\"><br>
Administrator Password (again) : <input type=\"password\" name=\"adminpassbis\"><br>
<br>
<input type=\"submit\" name=\"Submit\" value=\"Install\">
</form>";
}
?>
ik dacht wel dat je met php de chmod kan aanpassen, maar ook ik heb daar wel problemen mee gehad bij mijn hosting, maar dat was dan altijd eenvoudig te bypassen.
Je kunt met PHP alleen chmodden als je de betreffende map of het betreffende bestand ook met PHP aangemaakt hebt.
Is hier nu helemaal geen trucje voor? of zou ik iets aan dit setup bestand kunnen aanpassen zodat dit niet nodig is? want er zijn genoeg install en setup bestanden waarbij het niet nodig is om te chmodden.
Gewijzigd op 01/01/1970 01:00:00 door Rob
Ja, chmodden met je FTP programma.
nee dan werkt het niet meer... 500 error. de chmod is dan wel gedaan op de server, maar dan kan ik het bestand niet meer aanspreken.
Dit klinkt als 'superglobals' en dat zou betekenen dat jouw script simpel te hacken is. Het is te hopen dat jouw webserver zo snel mogelijk deze mogelijkheid uit zet. Gevolg: Jouw script zal niet meer werken...
Gebruik $_POST['submit'] voor een post of $_GET['submit'] voor een get. Uiteraard pas je alle overigen variabelen afkomstig van de browser, ook aan.
Gewijzigd op 01/01/1970 01:00:00 door Frank -
??? sorry, begrijp het even niet. dit is een setup scriptje die eenmalig gebruikt wordt en dan eraf wordt gehaald. ik zie de link met het chmod verhaal even niet.
Je maakt in je script geen gebruik van superglobals, zoals $_GET en $_POST. Bij veel providers werken scripts die op de ouderwetse manier gemaakt zijn, niet meer.
ah zooo... maar hoe zou ik dat in dit script kunnen aanpassen. kan ik i.p.v $submit dan zeggen $_POST['submit']
Ja, precies. En ook voor alle andere variabelen die uit je formulier komen.
Gewijzigd op 01/01/1970 01:00:00 door Rob