This repository has been archived by the owner on Sep 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
localcopy.ocmod.xml
94 lines (77 loc) · 2.98 KB
/
localcopy.ocmod.xml
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
<modification>
<name>Local copy OCMOD by iSenseLabs</name>
<version>1.2</version>
<link>http://isenselabs.com</link>
<author>iSenseLabs</author>
<code>isensealabs_quickfix_ocmod2</code>
<file path="admin/controller/extension/installer.php">
<operation>
<search ><![CDATA['url' => str_replace('&', '&', $this->url->link('extension/installer/ftp', 'token=' . $this->session->data['token'], 'SSL')),]]></search>
<add position="replace"><![CDATA['url' => str_replace('&', '&', $this->url->link('extension/installer/localcopy', 'token=' . $this->session->data['token'], 'SSL')),]]></add>
</operation>
<operation>
<search><![CDATA[public function unzip() {]]></search>
<add position="before"><![CDATA[
public function localcopy() {
$this->load->language('extension/installer');
$json = array();
if (!$this->user->hasPermission('modify', 'extension/installer')) {
$json['error'] = $this->language->get('error_permission');
}
if (VERSION == '2.0.0.0') {
$directory = DIR_DOWNLOAD . str_replace(array('../', '..\\', '..'), '', $this->request->post['path']) . '/upload/';
} else {
$directory = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->request->post['path']) . '/upload/';
}
if (!is_dir($directory)) {
$json['error'] = $this->language->get('error_directory');
}
if (!$json) {
// Get a list of files ready to upload
$files = array();
$path = array($directory . '*');
while (count($path) != 0) {
$next = array_shift($path);
foreach (glob($next) as $file) {
if (is_dir($file)) {
$path[] = $file . '/*';
}
$files[] = $file;
}
}
$root = dirname(DIR_APPLICATION).'/';
foreach ($files as $file) {
// Upload everything in the upload directory
$destination = substr($file, strlen($directory));
// Update from newer OpenCart versions:
if (substr($destination, 0, 5) == 'admin') {
$destination = DIR_APPLICATION . substr($destination, 5);
} else if (substr($destination, 0, 7) == 'catalog') {
$destination = DIR_CATALOG . substr($destination, 7);
} else if (substr($destination, 0, 5) == 'image') {
$destination = DIR_IMAGE . substr($destination, 5);
} else if (substr($destination, 0, 6) == 'system') {
$destination = DIR_SYSTEM . substr($destination, 6);
} else {
$destination = $root.$destination;
}
if (is_dir($file)) {
if (!file_exists($destination)) {
if (!mkdir($destination)) {
$json['error'] = sprintf($this->language->get('error_ftp_directory'), $destination);
}
}
}
if (is_file($file)) {
if (!copy($file, $destination)) {
$json['error'] = sprintf($this->language->get('error_ftp_file'), $file);
}
}
}
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}]]></add>
</operation>
</file>
</modification>