hpdl
|
251
|
1
|
<?php
|
hpdl
|
280
|
2
|
/*
|
|
3
|
$Id: $
|
|
4
|
|
|
5
|
osCommerce, Open Source E-Commerce Solutions
|
|
6
|
http://www.oscommerce.com
|
|
7
|
|
hpdl
|
1315
|
8
|
Copyright (c) 2007 osCommerce
|
hpdl
|
280
|
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
|
280
|
13
|
*/
|
|
14
|
|
hpdl
|
251
|
15
|
header('Cache-Control: no-cache, must-revalidate');
|
|
16
|
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
|
17
|
|
|
18
|
require('includes/application.php');
|
|
19
|
|
hpdl
|
268
|
20
|
$dir_fs_www_root = dirname(__FILE__);
|
hpdl
|
254
|
21
|
|
hpdl
|
251
|
22
|
if (isset($_GET['action']) && !empty($_GET['action'])) {
|
|
23
|
switch ($_GET['action']) {
|
|
24
|
case 'dbCheck':
|
hpdl
|
287
|
25
|
$db = array('DB_SERVER' => trim(urldecode($_GET['server'])),
|
|
26
|
'DB_SERVER_USERNAME' => trim(urldecode($_GET['username'])),
|
|
27
|
'DB_SERVER_PASSWORD' => trim(urldecode($_GET['password'])),
|
|
28
|
'DB_DATABASE' => trim(urldecode($_GET['name'])),
|
|
29
|
'DB_DATABASE_CLASS' => trim(urldecode($_GET['class']))
|
hpdl
|
251
|
30
|
);
|
|
31
|
|
hpdl
|
252
|
32
|
$osC_Database = osC_Database::connect($db['DB_SERVER'], $db['DB_SERVER_USERNAME'], $db['DB_SERVER_PASSWORD'], $db['DB_DATABASE_CLASS']);
|
hpdl
|
251
|
33
|
|
|
34
|
if ($osC_Database->isError() === false) {
|
hpdl
|
266
|
35
|
$osC_Database->selectDatabase($db['DB_DATABASE']);
|
hpdl
|
251
|
36
|
}
|
|
37
|
|
|
38
|
if ($osC_Database->isError()) {
|
frank
|
1137
|
39
|
echo '[[0|' . $osC_Database->getError() . ']]';
|
hpdl
|
251
|
40
|
} else {
|
frank
|
1137
|
41
|
echo '[[1]]';
|
hpdl
|
251
|
42
|
}
|
|
43
|
|
|
44
|
exit;
|
|
45
|
break;
|
hpdl
|
254
|
46
|
|
|
47
|
case 'dbImport':
|
hpdl
|
287
|
48
|
$db = array('DB_SERVER' => trim(urldecode($_GET['server'])),
|
|
49
|
'DB_SERVER_USERNAME' => trim(urldecode($_GET['username'])),
|
|
50
|
'DB_SERVER_PASSWORD' => trim(urldecode($_GET['password'])),
|
|
51
|
'DB_DATABASE' => trim(urldecode($_GET['name'])),
|
|
52
|
'DB_DATABASE_CLASS' => trim(urldecode($_GET['class'])),
|
|
53
|
'DB_INSERT_SAMPLE_DATA' => ((trim(urldecode($_GET['import'])) == '1') ? 'true' : 'false'),
|
|
54
|
'DB_TABLE_PREFIX' => trim(urldecode($_GET['prefix']))
|
hpdl
|
254
|
55
|
);
|
|
56
|
|
|
57
|
$osC_Database = osC_Database::connect($db['DB_SERVER'], $db['DB_SERVER_USERNAME'], $db['DB_SERVER_PASSWORD'], $db['DB_DATABASE_CLASS']);
|
|
58
|
|
|
59
|
if ($osC_Database->isError() === false) {
|
hpdl
|
266
|
60
|
$osC_Database->selectDatabase($db['DB_DATABASE']);
|
hpdl
|
254
|
61
|
}
|
|
62
|
|
|
63
|
if ($osC_Database->isError() === false) {
|
hpdl
|
268
|
64
|
$sql_file = $dir_fs_www_root . '/oscommerce.sql';
|
hpdl
|
254
|
65
|
|
|
66
|
$osC_Database->importSQL($sql_file, $db['DB_DATABASE'], $db['DB_TABLE_PREFIX']);
|
|
67
|
}
|
|
68
|
|
hpdl
|
264
|
69
|
if ( ($osC_Database->isError() === false) && ($db['DB_INSERT_SAMPLE_DATA'] == 'true') ) {
|
hpdl
|
268
|
70
|
$sql_file = $dir_fs_www_root . '/oscommerce_sample_data.sql';
|
hpdl
|
254
|
71
|
|
|
72
|
$osC_Database->importSQL($sql_file, $db['DB_DATABASE'], $db['DB_TABLE_PREFIX']);
|
|
73
|
}
|
|
74
|
|
hpdl
|
410
|
75
|
if ($osC_Database->isError() === false) {
|
|
76
|
foreach ($osC_Language->extractDefinitions('en_US.xml') as $def) {
|
|
77
|
$Qdef = $osC_Database->query('insert into :table_languages_definitions (languages_id, content_group, definition_key, definition_value) values (:languages_id, :content_group, :definition_key, :definition_value)');
|
|
78
|
$Qdef->bindTable(':table_languages_definitions', $db['DB_TABLE_PREFIX'] . 'languages_definitions');
|
|
79
|
$Qdef->bindInt(':languages_id', 1);
|
|
80
|
$Qdef->bindValue(':content_group', $def['group']);
|
|
81
|
$Qdef->bindValue(':definition_key', $def['key']);
|
|
82
|
$Qdef->bindValue(':definition_value', $def['value']);
|
|
83
|
$Qdef->execute();
|
|
84
|
}
|
|
85
|
|
|
86
|
$osC_DirectoryListing = new osC_DirectoryListing('../includes/languages/en_US');
|
|
87
|
$osC_DirectoryListing->setRecursive(true);
|
|
88
|
$osC_DirectoryListing->setIncludeDirectories(false);
|
|
89
|
$osC_DirectoryListing->setAddDirectoryToFilename(true);
|
|
90
|
$osC_DirectoryListing->setCheckExtension('xml');
|
|
91
|
|
|
92
|
foreach ($osC_DirectoryListing->getFiles() as $files) {
|
|
93
|
foreach ($osC_Language->extractDefinitions('en_US/' . $files['name']) as $def) {
|
|
94
|
$Qdef = $osC_Database->query('insert into :table_languages_definitions (languages_id, content_group, definition_key, definition_value) values (:languages_id, :content_group, :definition_key, :definition_value)');
|
|
95
|
$Qdef->bindTable(':table_languages_definitions', $db['DB_TABLE_PREFIX'] . 'languages_definitions');
|
|
96
|
$Qdef->bindInt(':languages_id', 1);
|
|
97
|
$Qdef->bindValue(':content_group', $def['group']);
|
|
98
|
$Qdef->bindValue(':definition_key', $def['key']);
|
|
99
|
$Qdef->bindValue(':definition_value', $def['value']);
|
|
100
|
$Qdef->execute();
|
|
101
|
}
|
|
102
|
}
|
|
103
|
}
|
|
104
|
|
hpdl
|
443
|
105
|
if ($osC_Database->isError() === false) {
|
|
106
|
define('DB_TABLE_PREFIX', $db['DB_TABLE_PREFIX']);
|
|
107
|
include('../includes/database_tables.php');
|
hpdl
|
554
|
108
|
|
|
109
|
/* HPDL
|
|
110
|
$services = array('banner',
|
|
111
|
'breadcrumb',
|
|
112
|
'category_path',
|
|
113
|
'core',
|
|
114
|
'currencies',
|
|
115
|
'debug',
|
|
116
|
'language',
|
|
117
|
'output_compression',
|
|
118
|
'recently_visited',
|
|
119
|
'reviews',
|
|
120
|
'session',
|
|
121
|
'simple_counter',
|
|
122
|
'specials',
|
|
123
|
'whos_online');
|
|
124
|
*/
|
|
125
|
$services = array('output_compression',
|
|
126
|
'session',
|
|
127
|
'language',
|
|
128
|
'debug',
|
|
129
|
'currencies',
|
|
130
|
'core',
|
|
131
|
'simple_counter',
|
|
132
|
'category_path',
|
|
133
|
'breadcrumb',
|
|
134
|
'whos_online',
|
hpdl
|
562
|
135
|
// 'banner',
|
hpdl
|
554
|
136
|
'specials',
|
|
137
|
'reviews',
|
|
138
|
'recently_visited');
|
|
139
|
|
|
140
|
$installed = array();
|
|
141
|
|
|
142
|
foreach ($services as $service) {
|
hpdl
|
1493
|
143
|
include('../admin/includes/modules/services/' . $service . '.php');
|
|
144
|
$class = 'osC_Services_' . $service . '_Admin';
|
hpdl
|
554
|
145
|
$module = new $class();
|
|
146
|
$module->install();
|
|
147
|
|
|
148
|
if (isset($module->depends)) {
|
|
149
|
if (is_string($module->depends) && (($key = array_search($module->depends, $installed)) !== false)) {
|
|
150
|
if (isset($installed[$key+1])) {
|
|
151
|
array_splice($installed, $key+1, 0, $service);
|
|
152
|
} else {
|
|
153
|
$installed[] = $service;
|
|
154
|
}
|
|
155
|
} elseif (is_array($module->depends)) {
|
|
156
|
foreach ($module->depends as $depends_module) {
|
|
157
|
if (($key = array_search($depends_module, $installed)) !== false) {
|
|
158
|
if (!isset($array_position) || ($key > $array_position)) {
|
|
159
|
$array_position = $key;
|
|
160
|
}
|
|
161
|
}
|
|
162
|
}
|
|
163
|
|
|
164
|
if (isset($array_position)) {
|
|
165
|
array_splice($installed, $array_position+1, 0, $service);
|
|
166
|
} else {
|
|
167
|
$installed[] = $service;
|
|
168
|
}
|
|
169
|
}
|
|
170
|
} elseif (isset($module->precedes)) {
|
|
171
|
if (is_string($module->precedes)) {
|
|
172
|
if ((($key = array_search($module->precedes, $installed)) !== false)) {
|
|
173
|
array_splice($installed, $key, 0, $service);
|
|
174
|
} else {
|
|
175
|
$installed[] = $service;
|
|
176
|
}
|
|
177
|
} elseif (is_array($module->precedes)) {
|
|
178
|
foreach ($module->precedes as $precedes_module) {
|
|
179
|
if (($key = array_search($precedes_module, $installed)) !== false) {
|
|
180
|
if (!isset($array_position) || ($key < $array_position)) {
|
|
181
|
$array_position = $key;
|
|
182
|
}
|
|
183
|
}
|
|
184
|
}
|
|
185
|
|
|
186
|
if (isset($array_position)) {
|
|
187
|
array_splice($installed, $array_position, 0, $service);
|
|
188
|
} else {
|
|
189
|
$installed[] = $service;
|
|
190
|
}
|
|
191
|
}
|
|
192
|
} else {
|
|
193
|
$installed[] = $service;
|
|
194
|
}
|
|
195
|
|
|
196
|
unset($array_position);
|
|
197
|
}
|
|
198
|
|
|
199
|
$Qs = $osC_Database->query('insert into :table_configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ("Service Modules", "MODULE_SERVICES_INSTALLED", :configuration_value, "Installed services modules", "6", "0", now())');
|
|
200
|
$Qs->bindTable(':table_configuration', TABLE_CONFIGURATION);
|
|
201
|
$Qs->bindValue(':configuration_value', implode(';', $installed));
|
|
202
|
$Qs->execute();
|
|
203
|
|
hpdl
|
443
|
204
|
include('includes/classes/payment.php');
|
|
205
|
include('includes/classes/shipping.php');
|
|
206
|
include('includes/classes/order_total.php');
|
|
207
|
|
hpdl
|
554
|
208
|
include('../admin/includes/modules/payment/cod.php');
|
hpdl
|
443
|
209
|
$module = new osC_Payment_cod();
|
|
210
|
$module->install();
|
|
211
|
|
hpdl
|
554
|
212
|
$Qupdate = $osC_Database->query('update :table_configuration set configuration_value = 1 where configuration_key = :configuration_key');
|
|
213
|
$Qupdate->bindTable(':table_configuration', TABLE_CONFIGURATION);
|
|
214
|
$Qupdate->bindValue(':configuration_key', 'MODULE_PAYMENT_COD_STATUS');
|
|
215
|
$Qupdate->execute();
|
hpdl
|
443
|
216
|
|
hpdl
|
782
|
217
|
include('../admin/includes/modules/shipping/flat.php');
|
hpdl
|
443
|
218
|
$module = new osC_Shipping_flat();
|
|
219
|
$module->install();
|
|
220
|
|
hpdl
|
782
|
221
|
include('../admin/includes/modules/order_total/sub_total.php');
|
hpdl
|
443
|
222
|
$module = new osC_OrderTotal_sub_total();
|
|
223
|
$module->install();
|
|
224
|
|
hpdl
|
782
|
225
|
include('../admin/includes/modules/order_total/shipping.php');
|
hpdl
|
443
|
226
|
$module = new osC_OrderTotal_shipping();
|
|
227
|
$module->install();
|
|
228
|
|
hpdl
|
782
|
229
|
include('../admin/includes/modules/order_total/tax.php');
|
hpdl
|
443
|
230
|
$module = new osC_OrderTotal_tax();
|
|
231
|
$module->install();
|
|
232
|
|
hpdl
|
782
|
233
|
include('../admin/includes/modules/order_total/total.php');
|
hpdl
|
443
|
234
|
$module = new osC_OrderTotal_total();
|
|
235
|
$module->install();
|
|
236
|
}
|
|
237
|
|
hpdl
|
280
|
238
|
if ( ($osC_Database->isError() === false) && ($db['DB_DATABASE_CLASS'] == 'mysql_innodb') ) {
|
hpdl
|
254
|
239
|
$Qinno = $osC_Database->query('show variables like "have_innodb"');
|
|
240
|
if (($Qinno->numberOfRows() === 1) && (strtolower($Qinno->value('Value')) == 'yes')) {
|
hpdl
|
1862
|
241
|
$database_tables = array('address_book', 'categories', 'categories_description', 'customers', 'manufacturers', 'manufacturers_info', 'orders', 'orders_products', 'orders_status', 'orders_status_history', 'orders_products_attributes', 'orders_products_download', 'orders_total', 'products', 'products_attributes', 'products_attributes_download', 'products_description', 'products_options', 'products_options_values', 'products_options_values_to_products_options', 'products_to_categories', 'reviews', 'shopping_carts', 'shopping_carts_custom_variants_values', 'weight_classes', 'weight_classes_rules');
|
hpdl
|
254
|
242
|
|
|
243
|
foreach ($database_tables as $table) {
|
|
244
|
$osC_Database->simpleQuery('alter table ' . $db['DB_TABLE_PREFIX'] . $table . ' type = innodb');
|
|
245
|
}
|
|
246
|
}
|
|
247
|
}
|
|
248
|
|
|
249
|
if ($osC_Database->isError()) {
|
frank
|
1137
|
250
|
echo '[[0|' . $osC_Database->getError() . ']]';
|
hpdl
|
254
|
251
|
} else {
|
frank
|
1137
|
252
|
echo '[[1]]';
|
hpdl
|
254
|
253
|
}
|
|
254
|
|
|
255
|
exit;
|
|
256
|
break;
|
|
257
|
|
hpdl
|
264
|
258
|
case 'dbImportSample':
|
hpdl
|
287
|
259
|
$db = array('DB_SERVER' => trim(urldecode($_GET['server'])),
|
|
260
|
'DB_SERVER_USERNAME' => trim(urldecode($_GET['username'])),
|
|
261
|
'DB_SERVER_PASSWORD' => trim(urldecode($_GET['password'])),
|
|
262
|
'DB_DATABASE' => trim(urldecode($_GET['name'])),
|
|
263
|
'DB_DATABASE_CLASS' => trim(urldecode($_GET['class'])),
|
|
264
|
'DB_TABLE_PREFIX' => trim(urldecode($_GET['prefix']))
|
hpdl
|
264
|
265
|
);
|
|
266
|
|
|
267
|
$osC_Database = osC_Database::connect($db['DB_SERVER'], $db['DB_SERVER_USERNAME'], $db['DB_SERVER_PASSWORD'], $db['DB_DATABASE_CLASS']);
|
|
268
|
|
|
269
|
if ($osC_Database->isError() === false) {
|
|
270
|
$osC_Database->selectDatabase($db['DB_DATABASE']);
|
|
271
|
}
|
|
272
|
|
|
273
|
if ($osC_Database->isError() === false) {
|
hpdl
|
268
|
274
|
$sql_file = $dir_fs_www_root . '/oscommerce_sample_data.sql';
|
hpdl
|
264
|
275
|
|
|
276
|
$osC_Database->importSQL($sql_file, $db['DB_DATABASE'], $db['DB_TABLE_PREFIX']);
|
|
277
|
}
|
|
278
|
|
|
279
|
if ($osC_Database->isError()) {
|
frank
|
1137
|
280
|
echo '[[0|' . $osC_Database->getError() . ']]';
|
hpdl
|
264
|
281
|
} else {
|
frank
|
1137
|
282
|
echo '[[1]]';
|
hpdl
|
264
|
283
|
}
|
|
284
|
|
|
285
|
exit;
|
|
286
|
break;
|
|
287
|
|
hpdl
|
254
|
288
|
case 'checkWorkDir':
|
hpdl
|
287
|
289
|
$directory = trim(urldecode($_GET['dir']));
|
|
290
|
|
|
291
|
if (file_exists($directory)) {
|
|
292
|
if (is_writeable($directory)) {
|
|
293
|
if (file_exists($directory . '/.htaccess') === false) {
|
|
294
|
if ($fp = @fopen($directory . '/.htaccess', 'w')) {
|
hpdl
|
285
|
295
|
flock($fp, 2); // LOCK_EX
|
|
296
|
fputs($fp, "<Files *>\nOrder Deny,Allow\nDeny from all\n</Files>");
|
|
297
|
flock($fp, 3); // LOCK_UN
|
|
298
|
fclose($fp);
|
|
299
|
}
|
|
300
|
}
|
hpdl
|
254
|
301
|
|
frank
|
1137
|
302
|
echo '[[1]]';
|
hpdl
|
254
|
303
|
} else {
|
frank
|
1137
|
304
|
echo '[[0|' . $directory . ']]';
|
hpdl
|
254
|
305
|
}
|
|
306
|
} else {
|
frank
|
1137
|
307
|
echo '[[-1|' . $directory . ']]';
|
hpdl
|
254
|
308
|
}
|
|
309
|
|
|
310
|
exit;
|
|
311
|
break;
|
hpdl
|
266
|
312
|
|
|
313
|
case 'getDirectoryPath':
|
hpdl
|
287
|
314
|
$directory = trim(urldecode($_GET['dir']));
|
hpdl
|
266
|
315
|
|
|
316
|
if (!is_dir($directory) || (false === $fh = @opendir($directory))) {
|
|
317
|
$query = basename($directory);
|
|
318
|
$directory = dirname($directory);
|
|
319
|
|
|
320
|
if ($fh = @opendir($directory)) {
|
|
321
|
$dirs = array();
|
|
322
|
while (false !== ($dir = readdir($fh))) {
|
|
323
|
if ( ($dir != '.') && ($dir != '..') && (substr($dir, 0, 1) != '.') && is_dir($directory . '/' . $dir)) {
|
|
324
|
if (strlen($query) > 1) {
|
|
325
|
if (substr($dir, 0, strlen($query)) == $query) {
|
|
326
|
$dirs[] = $directory . '/' . $dir;
|
|
327
|
}
|
|
328
|
} else {
|
|
329
|
$dirs[] = $directory . '/' . $dir;
|
|
330
|
}
|
|
331
|
}
|
|
332
|
}
|
|
333
|
closedir($fh);
|
|
334
|
|
|
335
|
if (sizeof($dirs) > 0) {
|
|
336
|
sort($dirs);
|
|
337
|
|
frank
|
1137
|
338
|
echo '[[0|' . implode(';', $dirs) . ']]';
|
hpdl
|
266
|
339
|
} else {
|
frank
|
1137
|
340
|
echo '[[-1|invalidPath]]';
|
hpdl
|
266
|
341
|
}
|
|
342
|
} else {
|
frank
|
1137
|
343
|
echo '[[-1|invalidPath]]';
|
hpdl
|
266
|
344
|
}
|
|
345
|
} else {
|
frank
|
1137
|
346
|
echo '[[1|' . $directory . ']]';
|
hpdl
|
266
|
347
|
}
|
|
348
|
|
|
349
|
exit;
|
|
350
|
break;
|
hpdl
|
251
|
351
|
}
|
|
352
|
}
|
|
353
|
|
frank
|
1137
|
354
|
echo '[[-100|noActionError]]';
|
hpdl
|
251
|
355
|
?>
|