hpdl
|
1
|
1
|
<?php
|
|
2
|
/*
|
hpdl
|
642
|
3
|
$Id: install_4.php 1859 2009-03-06 23:21:50Z hpdl $
|
hpdl
|
1
|
4
|
|
|
5
|
osCommerce, Open Source E-Commerce Solutions
|
|
6
|
http://www.oscommerce.com
|
|
7
|
|
hpdl
|
1315
|
8
|
Copyright (c) 2007 osCommerce
|
hpdl
|
1
|
9
|
|
hpdl
|
1498
|
10
|
This program is free software; you can redistribute it and/or modify
|
|
11
|
it under the terms of the GNU General Public License v2 (1991)
|
|
12
|
as published by the Free Software Foundation.
|
hpdl
|
1
|
13
|
*/
|
|
|
267
|
14
|
|
hpdl
|
451
|
15
|
define('DB_TABLE_PREFIX', $_POST['DB_TABLE_PREFIX']);
|
|
16
|
include('../includes/database_tables.php');
|
|
|
440
|
17
|
|
hpdl
|
451
|
18
|
$osC_Database = osC_Database::connect($_POST['DB_SERVER'], $_POST['DB_SERVER_USERNAME'], $_POST['DB_SERVER_PASSWORD'], $_POST['DB_DATABASE_CLASS']);
|
|
19
|
$osC_Database->selectDatabase($_POST['DB_DATABASE']);
|
|
|
267
|
20
|
|
hpdl
|
451
|
21
|
$Qupdate = $osC_Database->query('update :table_configuration set configuration_value = :configuration_value where configuration_key = :configuration_key');
|
|
22
|
$Qupdate->bindTable(':table_configuration', TABLE_CONFIGURATION);
|
|
23
|
$Qupdate->bindValue(':configuration_value', $_POST['CFG_STORE_NAME']);
|
|
24
|
$Qupdate->bindValue(':configuration_key', 'STORE_NAME');
|
|
25
|
$Qupdate->execute();
|
|
|
267
|
26
|
|
hpdl
|
451
|
27
|
$Qupdate = $osC_Database->query('update :table_configuration set configuration_value = :configuration_value where configuration_key = :configuration_key');
|
|
28
|
$Qupdate->bindTable(':table_configuration', TABLE_CONFIGURATION);
|
|
29
|
$Qupdate->bindValue(':configuration_value', $_POST['CFG_STORE_OWNER_NAME']);
|
|
30
|
$Qupdate->bindValue(':configuration_key', 'STORE_OWNER');
|
|
31
|
$Qupdate->execute();
|
|
|
267
|
32
|
|
hpdl
|
451
|
33
|
$Qupdate = $osC_Database->query('update :table_configuration set configuration_value = :configuration_value where configuration_key = :configuration_key');
|
|
34
|
$Qupdate->bindTable(':table_configuration', TABLE_CONFIGURATION);
|
|
35
|
$Qupdate->bindValue(':configuration_value', $_POST['CFG_STORE_OWNER_EMAIL_ADDRESS']);
|
|
36
|
$Qupdate->bindValue(':configuration_key', 'STORE_OWNER_EMAIL_ADDRESS');
|
|
37
|
$Qupdate->execute();
|
|
38
|
|
|
39
|
if (!empty($_POST['CFG_STORE_OWNER_NAME']) && !empty($_POST['CFG_STORE_OWNER_EMAIL_ADDRESS'])) {
|
|
|
267
|
40
|
$Qupdate = $osC_Database->query('update :table_configuration set configuration_value = :configuration_value where configuration_key = :configuration_key');
|
|
|
440
|
41
|
$Qupdate->bindTable(':table_configuration', TABLE_CONFIGURATION);
|
hpdl
|
451
|
42
|
$Qupdate->bindValue(':configuration_value', '"' . $_POST['CFG_STORE_OWNER_NAME'] . '" <' . $_POST['CFG_STORE_OWNER_EMAIL_ADDRESS'] . '>');
|
|
43
|
$Qupdate->bindValue(':configuration_key', 'EMAIL_FROM');
|
|
|
267
|
44
|
$Qupdate->execute();
|
hpdl
|
451
|
45
|
}
|
|
|
267
|
46
|
|
hpdl
|
451
|
47
|
$Qcheck = $osC_Database->query('select user_name from :table_administrators where user_name = :user_name');
|
|
48
|
$Qcheck->bindTable(':table_administrators', TABLE_ADMINISTRATORS);
|
|
49
|
$Qcheck->bindValue(':user_name', $_POST['CFG_ADMINISTRATOR_USERNAME']);
|
|
50
|
$Qcheck->execute();
|
hpdl
|
271
|
51
|
|
hpdl
|
451
|
52
|
if ($Qcheck->numberOfRows()) {
|
hpdl
|
1113
|
53
|
$Qadmin = $osC_Database->query('update :table_administrators set user_password = :user_password where user_name = :user_name');
|
hpdl
|
451
|
54
|
} else {
|
hpdl
|
1113
|
55
|
$Qadmin = $osC_Database->query('insert into :table_administrators (user_name, user_password) values (:user_name, :user_password)');
|
|
|
267
|
56
|
}
|
hpdl
|
451
|
57
|
$Qadmin->bindTable(':table_administrators', TABLE_ADMINISTRATORS);
|
hpdl
|
757
|
58
|
$Qadmin->bindValue(':user_password', osc_encrypt_string(trim($_POST['CFG_ADMINISTRATOR_PASSWORD'])));
|
hpdl
|
451
|
59
|
$Qadmin->bindValue(':user_name', $_POST['CFG_ADMINISTRATOR_USERNAME']);
|
|
60
|
$Qadmin->execute();
|
hpdl
|
1078
|
61
|
|
|
62
|
$Qadmin = $osC_Database->query('select id from :table_administrators where user_name = :user_name');
|
|
63
|
$Qadmin->bindTable(':table_administrators', TABLE_ADMINISTRATORS);
|
|
64
|
$Qadmin->bindValue(':user_name', $_POST['CFG_ADMINISTRATOR_USERNAME']);
|
|
65
|
$Qadmin->execute();
|
|
66
|
|
|
67
|
$Qcheck = $osC_Database->query('select module from :table_administrators_access where administrators_id = :administrators_id limit 1');
|
|
68
|
$Qcheck->bindTable(':table_administrators_access', TABLE_ADMINISTRATORS_ACCESS);
|
|
69
|
$Qcheck->bindInt(':administrators_id', $Qadmin->valueInt('id'));
|
|
70
|
$Qcheck->execute();
|
|
71
|
|
|
72
|
if ($Qcheck->numberOfRows()) {
|
|
73
|
$Qdel = $osC_Database->query('delete from :table_administrators_access where administrators_id = :administrators_id');
|
|
74
|
$Qdel->bindTable(':table_administrators_access', TABLE_ADMINISTRATORS_ACCESS);
|
|
75
|
$Qdel->bindInt(':administrators_id', $Qadmin->valueInt('id'));
|
|
76
|
$Qdel->execute();
|
|
77
|
}
|
|
78
|
|
|
79
|
$Qaccess = $osC_Database->query('insert into :table_administrators_access (administrators_id, module) values (:administrators_id, :module)');
|
|
80
|
$Qaccess->bindTable(':table_administrators_access', TABLE_ADMINISTRATORS_ACCESS);
|
|
81
|
$Qaccess->bindInt(':administrators_id', $Qadmin->valueInt('id'));
|
|
82
|
$Qaccess->bindValue(':module', '*');
|
|
83
|
$Qaccess->execute();
|
hpdl
|
1
|
84
|
?>
|
|
85
|
|
hpdl
|
250
|
86
|
<div class="mainBlock">
|
hpdl
|
266
|
87
|
<div class="stepsBox">
|
|
88
|
<ol>
|
|
89
|
<li><?php echo $osC_Language->get('box_steps_step_1'); ?></li>
|
|
90
|
<li><?php echo $osC_Language->get('box_steps_step_2'); ?></li>
|
|
91
|
<li><?php echo $osC_Language->get('box_steps_step_3'); ?></li>
|
hpdl
|
466
|
92
|
<li style="font-weight: bold;"><?php echo $osC_Language->get('box_steps_step_4'); ?></li>
|
hpdl
|
266
|
93
|
</ol>
|
|
94
|
</div>
|
hpdl
|
254
|
95
|
|
hpdl
|
266
|
96
|
<h1><?php echo $osC_Language->get('page_title_installation'); ?></h1>
|
hpdl
|
1
|
97
|
|
hpdl
|
266
|
98
|
<?php echo $osC_Language->get('text_installation'); ?>
|
hpdl
|
250
|
99
|
</div>
|
hpdl
|
1
|
100
|
|
hpdl
|
250
|
101
|
<div class="contentBlock">
|
hpdl
|
255
|
102
|
<div class="infoPane">
|
hpdl
|
466
|
103
|
<h3><?php echo $osC_Language->get('box_info_step_4_title'); ?></h3>
|
hpdl
|
255
|
104
|
|
|
105
|
<div class="infoPaneContents">
|
hpdl
|
466
|
106
|
<?php echo $osC_Language->get('box_info_step_4_text'); ?>
|
hpdl
|
255
|
107
|
</div>
|
|
108
|
</div>
|
|
109
|
|
hpdl
|
250
|
110
|
<div class="contentPane">
|
hpdl
|
466
|
111
|
<h2><?php echo $osC_Language->get('page_heading_step_4'); ?></h2>
|
hpdl
|
250
|
112
|
|
hpdl
|
1
|
113
|
<?php
|
hpdl
|
451
|
114
|
$dir_fs_document_root = $_POST['DIR_FS_DOCUMENT_ROOT'];
|
|
115
|
if ((substr($dir_fs_document_root, -1) != '\\') && (substr($dir_fs_document_root, -1) != '/')) {
|
|
116
|
if (strrpos($dir_fs_document_root, '\\') !== false) {
|
|
117
|
$dir_fs_document_root .= '\\';
|
|
118
|
} else {
|
|
119
|
$dir_fs_document_root .= '/';
|
hpdl
|
263
|
120
|
}
|
hpdl
|
451
|
121
|
}
|
hpdl
|
263
|
122
|
|
hpdl
|
451
|
123
|
$http_url = parse_url($_POST['HTTP_WWW_ADDRESS']);
|
|
124
|
$http_server = $http_url['scheme'] . '://' . $http_url['host'];
|
|
125
|
$http_catalog = $http_url['path'];
|
|
126
|
if (isset($http_url['port']) && !empty($http_url['port'])) {
|
|
127
|
$http_server .= ':' . $http_url['port'];
|
|
128
|
}
|
|
|
267
|
129
|
|
hpdl
|
451
|
130
|
if (substr($http_catalog, -1) != '/') {
|
|
131
|
$http_catalog .= '/';
|
|
132
|
}
|
|
|
267
|
133
|
|
hpdl
|
451
|
134
|
$http_work_directory = $_POST['HTTP_WORK_DIRECTORY'];
|
|
135
|
if (substr($http_work_directory, -1) != '/') {
|
|
136
|
$http_work_directory .= '/';
|
|
137
|
}
|
|
|
267
|
138
|
|
hpdl
|
451
|
139
|
$osC_DirectoryListing = new osC_DirectoryListing($http_work_directory);
|
|
140
|
$osC_DirectoryListing->setIncludeDirectories(false);
|
|
141
|
$osC_DirectoryListing->setCheckExtension('cache');
|
|
|
441
|
142
|
|
hpdl
|
451
|
143
|
foreach ($osC_DirectoryListing->getFiles() as $files) {
|
|
144
|
@unlink($osC_DirectoryListing->getDirectory() . '/' . $files['name']);
|
|
145
|
}
|
|
|
441
|
146
|
|
hpdl
|
451
|
147
|
$file_contents = '<?php' . "\n" .
|
|
148
|
' define(\'HTTP_SERVER\', \'' . $http_server . '\');' . "\n" .
|
|
149
|
' define(\'HTTPS_SERVER\', \'' . $http_server . '\');' . "\n" .
|
|
150
|
' define(\'ENABLE_SSL\', false);' . "\n" .
|
hpdl
|
1320
|
151
|
' define(\'HTTP_COOKIE_DOMAIN\', \'' . $http_url['host'] . '\');' . "\n" .
|
|
152
|
' define(\'HTTPS_COOKIE_DOMAIN\', \'' . $http_url['host'] . '\');' . "\n" .
|
|
153
|
' define(\'HTTP_COOKIE_PATH\', \'' . $http_catalog . '\');' . "\n" .
|
|
154
|
' define(\'HTTPS_COOKIE_PATH\', \'' . $http_catalog . '\');' . "\n" .
|
hpdl
|
451
|
155
|
' define(\'DIR_WS_HTTP_CATALOG\', \'' . $http_catalog . '\');' . "\n" .
|
|
156
|
' define(\'DIR_WS_HTTPS_CATALOG\', \'' . $http_catalog . '\');' . "\n" .
|
|
157
|
' define(\'DIR_WS_IMAGES\', \'images/\');' . "\n\n" .
|
|
158
|
' define(\'DIR_WS_DOWNLOAD_PUBLIC\', \'pub/\');' . "\n" .
|
|
159
|
' define(\'DIR_FS_CATALOG\', \'' . $dir_fs_document_root . '\');' . "\n" .
|
|
160
|
' define(\'DIR_FS_WORK\', \'' . $http_work_directory . '\');' . "\n" .
|
|
161
|
' define(\'DIR_FS_DOWNLOAD\', DIR_FS_CATALOG . \'download/\');' . "\n" .
|
|
162
|
' define(\'DIR_FS_DOWNLOAD_PUBLIC\', DIR_FS_CATALOG . \'pub/\');' . "\n" .
|
|
163
|
' define(\'DIR_FS_BACKUP\', \'' . $dir_fs_document_root . 'admin/backups/\');' . "\n\n" .
|
|
164
|
' define(\'DB_SERVER\', \'' . $_POST['DB_SERVER'] . '\');' . "\n" .
|
|
165
|
' define(\'DB_SERVER_USERNAME\', \'' . $_POST['DB_SERVER_USERNAME'] . '\');' . "\n" .
|
|
166
|
' define(\'DB_SERVER_PASSWORD\', \'' . $_POST['DB_SERVER_PASSWORD']. '\');' . "\n" .
|
|
167
|
' define(\'DB_DATABASE\', \'' . $_POST['DB_DATABASE']. '\');' . "\n" .
|
hpdl
|
1320
|
168
|
' define(\'DB_DATABASE_CLASS\', \'' . $_POST['DB_DATABASE_CLASS'] . '\');' . "\n" .
|
hpdl
|
451
|
169
|
' define(\'DB_TABLE_PREFIX\', \'' . $_POST['DB_TABLE_PREFIX']. '\');' . "\n" .
|
|
170
|
' define(\'USE_PCONNECT\', \'false\');' . "\n" .
|
hpdl
|
1859
|
171
|
' define(\'STORE_SESSIONS\', \'database\');' . "\n" .
|
hpdl
|
451
|
172
|
'?>';
|
|
|
267
|
173
|
|
hpdl
|
451
|
174
|
if (file_exists($dir_fs_document_root . 'includes/configure.php') && !is_writeable($dir_fs_document_root . 'includes/configure.php')) {
|
|
175
|
@chmod($dir_fs_document_root . 'includes/configure.php', 0777);
|
|
176
|
}
|
|
|
267
|
177
|
|
hpdl
|
451
|
178
|
if (file_exists($dir_fs_document_root . 'includes/configure.php') && is_writeable($dir_fs_document_root . 'includes/configure.php')) {
|
|
179
|
$fp = fopen($dir_fs_document_root . 'includes/configure.php', 'w');
|
|
180
|
fputs($fp, $file_contents);
|
|
181
|
fclose($fp);
|
hpdl
|
924
|
182
|
?>
|
|
183
|
|
|
184
|
<p><?php echo $osC_Language->get('text_successful_installation'); ?></p>
|
|
185
|
|
|
186
|
<?php
|
hpdl
|
451
|
187
|
} else {
|
hpdl
|
1
|
188
|
?>
|
|
|
267
|
189
|
|
hpdl
|
642
|
190
|
<form name="install" action="install.php?step=4" method="post">
|
hpdl
|
1
|
191
|
|
hpdl
|
451
|
192
|
<div class="noticeBox">
|
|
193
|
<?php echo sprintf($osC_Language->get('error_configuration_file_not_writeable'), $dir_fs_document_root . 'includes/configure.php'); ?>
|
hpdl
|
1
|
194
|
|
hpdl
|
924
|
195
|
<p align="right"><?php echo '<input type="image" src="templates/' . $template . '/languages/' . $osC_Language->getCode() . '/images/buttons/retry.gif" border="0" alt="' . $osC_Language->get('image_button_retry') . '" />'; ?></p>
|
hpdl
|
1
|
196
|
|
hpdl
|
451
|
197
|
<?php echo $osC_Language->get('error_configuration_file_alternate_method'); ?>
|
|
|
267
|
198
|
|
hpdl
|
1320
|
199
|
<?php echo osc_draw_textarea_field('contents', $file_contents, 60, 5, 'readonly="readonly" style="width: 100%; height: 120px;"', false); ?>
|
hpdl
|
451
|
200
|
</div>
|
|
|
267
|
201
|
|
|
202
|
<?php
|
hpdl
|
451
|
203
|
foreach ($_POST as $key => $value) {
|
|
204
|
if ($key != 'x' && $key != 'y') {
|
|
205
|
if (is_array($value)) {
|
|
206
|
for ($i=0, $n=sizeof($value); $i<$n; $i++) {
|
|
207
|
echo osc_draw_hidden_field($key . '[]', $value[$i]);
|
hpdl
|
1
|
208
|
}
|
hpdl
|
451
|
209
|
} else {
|
|
210
|
echo osc_draw_hidden_field($key, $value);
|
hpdl
|
1
|
211
|
}
|
|
212
|
}
|
|
|
267
|
213
|
}
|
hpdl
|
1
|
214
|
?>
|
|
215
|
|
hpdl
|
451
|
216
|
</form>
|
hpdl
|
1
|
217
|
|
hpdl
|
924
|
218
|
<p><?php echo $osC_Language->get('text_go_to_shop_after_cfg_file_is_saved'); ?></p>
|
|
219
|
|
hpdl
|
1
|
220
|
<?php
|
hpdl
|
451
|
221
|
}
|
hpdl
|
263
|
222
|
?>
|
|
223
|
|
|
224
|
<br />
|
|
225
|
|
|
226
|
<table border="0" width="99%" cellspacing="0" cellpadding="0">
|
|
227
|
<tr>
|
hpdl
|
451
|
228
|
<td align="center" width="50%"><a href="<?php echo $http_server . $http_catalog . 'index.php'; ?>" target="_blank"><img src="images/button_catalog.gif" border="0" alt="Catalog" /></a></td>
|
|
229
|
<td align="center" width="50%"><a href="<?php echo $http_server . $http_catalog . 'admin/index.php'; ?>" target="_blank"><img src="images/button_administration_tool.gif" border="0" alt="Administration Tool" /></a></td>
|
hpdl
|
263
|
230
|
</tr>
|
|
231
|
</table>
|
hpdl
|
250
|
232
|
</div>
|
|
233
|
</div>
|