Mage_Downloader - Version 1.7.0.0

Version Notes

1.7.0.0

Download this release

Release Info

Developer Magento Core Team
Extension Mage_Downloader
Version 1.7.0.0
Comparing to
See all releases


Code changes from version 1.6.2.0 to 1.7.0.0

Files changed (123) hide show
  1. .htaccess +23 -0
  2. downloader/Maged/Connect.php +156 -106
  3. downloader/Maged/Connect/Frontend.php +1 -1
  4. downloader/Maged/Controller.php +120 -4
  5. downloader/Maged/Exception.php +1 -1
  6. downloader/Maged/Model.php +1 -1
  7. downloader/Maged/Model/Config.php +1 -1
  8. downloader/Maged/Model/Config/Abstract.php +1 -1
  9. downloader/Maged/Model/Config/Community.php +1 -1
  10. downloader/Maged/Model/Config/Interface.php +1 -1
  11. downloader/Maged/Model/Connect.php +1 -1
  12. downloader/Maged/Model/Connect/Request.php +1 -1
  13. downloader/Maged/Model/Dowloader.php +1 -1
  14. downloader/Maged/Model/Session.php +1 -1
  15. downloader/Maged/View.php +1 -1
  16. downloader/favicon.ico +0 -0
  17. downloader/index.php +1 -1
  18. downloader/lib/Mage/Archive.php +6 -6
  19. downloader/lib/Mage/Archive/Abstract.php +7 -4
  20. downloader/lib/Mage/Archive/Bz.php +25 -15
  21. downloader/lib/Mage/Archive/Gz.php +25 -15
  22. downloader/lib/Mage/Archive/Helper/File.php +274 -0
  23. downloader/lib/Mage/Archive/Helper/File/Bz.php +92 -0
  24. downloader/lib/Mage/Archive/Helper/File/Gz.php +83 -0
  25. downloader/lib/Mage/Archive/Interface.php +1 -1
  26. downloader/lib/Mage/Archive/Tar.php +366 -50
  27. downloader/lib/Mage/Autoload/Simple.php +1 -1
  28. downloader/lib/Mage/Backup.php +59 -0
  29. downloader/lib/Mage/Backup/Abstract.php +318 -0
  30. downloader/lib/Mage/Backup/Archive/Tar.php +82 -0
  31. downloader/lib/Mage/Backup/Db.php +119 -0
  32. downloader/lib/Mage/Backup/Exception.php +36 -0
  33. downloader/lib/Mage/Backup/Exception/CantLoadSnapshot.php +36 -0
  34. downloader/lib/Mage/Backup/Exception/FtpConnectionFailed.php +36 -0
  35. downloader/lib/Mage/Backup/Exception/FtpValidationFailed.php +36 -0
  36. downloader/lib/Mage/Backup/Exception/NotEnoughFreeSpace.php +36 -0
  37. downloader/lib/Mage/Backup/Exception/NotEnoughPermissions.php +36 -0
  38. downloader/lib/Mage/Backup/Filesystem.php +284 -0
  39. downloader/lib/Mage/Backup/Filesystem/Helper.php +137 -0
  40. downloader/lib/Mage/Backup/Filesystem/Iterator/File.php +112 -0
  41. downloader/lib/Mage/Backup/Filesystem/Iterator/Filter.php +77 -0
  42. downloader/lib/Mage/Backup/Filesystem/Rollback/Abstract.php +57 -0
  43. downloader/lib/Mage/Backup/Filesystem/Rollback/Fs.php +78 -0
  44. downloader/lib/Mage/Backup/Filesystem/Rollback/Ftp.php +194 -0
  45. downloader/lib/Mage/Backup/Interface.php +88 -0
  46. downloader/lib/Mage/Backup/Media.php +99 -0
  47. downloader/lib/Mage/Backup/Nomedia.php +82 -0
  48. downloader/lib/Mage/Backup/Snapshot.php +140 -0
  49. downloader/lib/Mage/Connect/Channel/Generator.php +1 -1
  50. downloader/lib/Mage/Connect/Channel/Parser.php +1 -1
  51. downloader/lib/Mage/Connect/Channel/VO.php +1 -1
  52. downloader/lib/Mage/Connect/Command.php +85 -32
  53. downloader/lib/Mage/Connect/Command/Channels.php +1 -1
  54. downloader/lib/Mage/Connect/Command/Channels_Header.php +1 -1
  55. downloader/lib/Mage/Connect/Command/Config.php +13 -10
  56. downloader/lib/Mage/Connect/Command/Config_Header.php +1 -1
  57. downloader/lib/Mage/Connect/Command/Install.php +104 -125
  58. downloader/lib/Mage/Connect/Command/Install_Header.php +1 -1
  59. downloader/lib/Mage/Connect/Command/Package.php +1 -1
  60. downloader/lib/Mage/Connect/Command/Package_Header.php +1 -1
  61. downloader/lib/Mage/Connect/Command/Registry.php +1 -1
  62. downloader/lib/Mage/Connect/Command/Registry_Header.php +1 -1
  63. downloader/lib/Mage/Connect/Command/Remote.php +1 -1
  64. downloader/lib/Mage/Connect/Command/Remote_Header.php +1 -1
  65. downloader/lib/Mage/Connect/Config.php +167 -14
  66. downloader/lib/Mage/Connect/Converter.php +1 -1
  67. downloader/lib/Mage/Connect/Frontend.php +38 -22
  68. downloader/lib/Mage/Connect/Frontend/CLI.php +1 -1
  69. downloader/lib/Mage/Connect/Ftp.php +58 -48
  70. downloader/lib/Mage/Connect/Loader.php +4 -5
  71. downloader/lib/Mage/Connect/Loader/Ftp.php +1 -1
  72. downloader/lib/Mage/Connect/Package.php +1 -1
  73. downloader/lib/Mage/Connect/Package/Hotfix.php +1 -1
  74. downloader/lib/Mage/Connect/Package/Reader.php +1 -1
  75. downloader/lib/Mage/Connect/Package/Target.php +1 -1
  76. downloader/lib/Mage/Connect/Package/VO.php +1 -1
  77. downloader/lib/Mage/Connect/Package/Writer.php +1 -1
  78. downloader/lib/Mage/Connect/Packager.php +45 -40
  79. downloader/lib/Mage/Connect/Rest.php +85 -61
  80. downloader/lib/Mage/Connect/Singleconfig.php +221 -94
  81. downloader/lib/Mage/Connect/Structures/Graph.php +1 -1
  82. downloader/lib/Mage/Connect/Structures/Node.php +1 -1
  83. downloader/lib/Mage/Connect/Validator.php +106 -65
  84. downloader/lib/Mage/DB/Exception.php +1 -1
  85. downloader/lib/Mage/DB/Mysqli.php +1 -1
  86. downloader/lib/Mage/Exception.php +1 -1
  87. downloader/lib/Mage/HTTP/Client.php +10 -12
  88. downloader/lib/Mage/HTTP/Client/Curl.php +1 -1
  89. downloader/lib/Mage/HTTP/Client/Socket.php +1 -1
  90. downloader/lib/Mage/HTTP/IClient.php +1 -1
  91. downloader/lib/Mage/System/Args.php +3 -3
  92. downloader/lib/Mage/System/Dirs.php +16 -16
  93. downloader/lib/Mage/System/Ftp.php +509 -0
  94. downloader/lib/Mage/Xml/Generator.php +1 -1
  95. downloader/lib/Mage/Xml/Parser.php +1 -1
  96. downloader/mage.php +1 -1
  97. downloader/skin/boxes.css +1 -1
  98. downloader/skin/ie7boxes.css +1 -1
  99. downloader/skin/ieboxes.css +1 -1
  100. downloader/skin/install/boxes.css +1 -1
  101. downloader/skin/install/clears.css +1 -1
  102. downloader/skin/install/ie7minus.css +1 -1
  103. downloader/skin/install/iestyles.css +1 -1
  104. downloader/skin/install/reset.css +1 -1
  105. downloader/target.xml +15 -0
  106. downloader/template/connect/iframe.phtml +6 -2
  107. downloader/template/connect/packages.phtml +48 -6
  108. downloader/template/connect/packages_prepare.phtml +1 -1
  109. downloader/template/exception.phtml +1 -1
  110. downloader/template/footer.phtml +2 -2
  111. downloader/template/header.phtml +1 -1
  112. downloader/template/index.phtml +1 -1
  113. downloader/template/install/download.phtml +17 -7
  114. downloader/template/install/footer.phtml +2 -2
  115. downloader/template/install/header.phtml +1 -1
  116. downloader/template/install/writable.phtml +1 -1
  117. downloader/template/login.phtml +1 -1
  118. downloader/template/messages.phtml +1 -1
  119. downloader/template/noroute.phtml +1 -1
  120. downloader/template/settings.phtml +1 -1
  121. downloader/template/writable.phtml +1 -1
  122. index.php +10 -3
  123. package.xml +5 -5
.htaccess CHANGED
@@ -122,12 +122,35 @@
122
 
123
  #RewriteBase /magento/
124
 
 
 
 
 
 
 
 
 
 
 
125
  ############################################
126
  ## workaround for HTTP authorization
127
  ## in CGI environment
128
 
129
  RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
130
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  ############################################
132
  ## always send 404 on missing files in these folders
133
 
122
 
123
  #RewriteBase /magento/
124
 
125
+ ############################################
126
+ ## uncomment next line to enable light API calls processing
127
+
128
+ # RewriteRule ^api/([a-z][0-9a-z_]+)/?$ api.php?type=$1 [QSA,L]
129
+
130
+ ############################################
131
+ ## rewrite API2 calls to api.php (by now it is REST only)
132
+
133
+ RewriteRule ^api/rest api.php?type=rest [QSA,L]
134
+
135
  ############################################
136
  ## workaround for HTTP authorization
137
  ## in CGI environment
138
 
139
  RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
140
 
141
+ ############################################
142
+ ## TRACE and TRACK HTTP methods disabled to prevent XSS attacks
143
+
144
+ RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
145
+ RewriteRule .* - [L,R=405]
146
+
147
+ ############################################
148
+ ## redirect for mobile user agents
149
+
150
+ #RewriteCond %{REQUEST_URI} !^/mobiledirectoryhere/.*$
151
+ #RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
152
+ #RewriteRule ^(.*)$ /mobiledirectoryhere/ [L,R=302]
153
+
154
  ############################################
155
  ## always send 404 on missing files in these folders
156
 
downloader/Maged/Connect.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_Connect
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
@@ -55,17 +55,17 @@ class Maged_Connect
55
  {
56
 
57
  /**
58
- * Object of config
59
- *
60
- * @var Mage_Connect_Config
61
- */
62
  protected $_config;
63
 
64
  /**
65
- * Object of single config
66
- *
67
- * @var Mage_Connect_Singleconfig
68
- */
69
  protected $_sconfig;
70
 
71
  /**
@@ -76,22 +76,29 @@ class Maged_Connect
76
  protected $_frontend;
77
 
78
  /**
79
- * Internal cache for command objects
80
- *
81
- * @var array
82
- */
83
  protected $_cmdCache = array();
84
 
85
  /**
86
- * Instance of class
87
- *
88
- * @var Maged_Connect
89
- */
 
 
 
 
 
 
 
90
  static protected $_instance;
91
 
92
  /**
93
- * Constructor
94
- */
95
  public function __construct()
96
  {
97
  $this->getConfig();
@@ -100,10 +107,20 @@ class Maged_Connect
100
  }
101
 
102
  /**
103
- * Initialize instance
104
- *
105
- * @return Maged_Connect
106
- */
 
 
 
 
 
 
 
 
 
 
107
  public static function getInstance()
108
  {
109
  if (!self::$_instance) {
@@ -113,10 +130,10 @@ class Maged_Connect
113
  }
114
 
115
  /**
116
- * Retrieve object of config and set it to Mage_Connect_Command
117
- *
118
- * @return Mage_Connect_Config
119
- */
120
  public function getConfig()
121
  {
122
  if (!$this->_config) {
@@ -135,15 +152,19 @@ class Maged_Connect
135
  }
136
 
137
  /**
138
- * Retrieve object of single config and set it to Mage_Connect_Command
139
- *
140
- * @param bool $reload
141
- * @return Mage_Connect_Singleconfig
142
- */
143
  public function getSingleConfig($reload = false)
144
  {
145
  if(!$this->_sconfig || $reload) {
146
- $this->_sconfig = new Mage_Connect_Singleconfig($this->getConfig()->magento_root . DIRECTORY_SEPARATOR . $this->getConfig()->downloader_path . DIRECTORY_SEPARATOR . Mage_Connect_Singleconfig::DEFAULT_SCONFIG_FILENAME);
 
 
 
 
147
  }
148
  Mage_Connect_Command::setSconfig($this->_sconfig);
149
  return $this->_sconfig;
@@ -151,10 +172,10 @@ class Maged_Connect
151
  }
152
 
153
  /**
154
- * Retrieve object of frontend and set it to Mage_Connect_Command
155
- *
156
- * @return Maged_Connect_Frontend
157
- */
158
  public function getFrontend()
159
  {
160
  if (!$this->_frontend) {
@@ -165,30 +186,30 @@ class Maged_Connect
165
  }
166
 
167
  /**
168
- * Retrieve lof from frontend
169
- *
170
- * @return array
171
- */
172
  public function getLog()
173
  {
174
  return $this->getFrontend()->getLog();
175
  }
176
 
177
  /**
178
- * Retrieve output from frontend
179
- *
180
- * @return array
181
- */
182
  public function getOutput()
183
  {
184
  return $this->getFrontend()->getOutput();
185
  }
186
 
187
  /**
188
- * Clean registry
189
- *
190
- * @return Maged_Connect
191
- */
192
  public function cleanSconfig()
193
  {
194
  $this->getSingleConfig()->clear();
@@ -196,11 +217,11 @@ class Maged_Connect
196
  }
197
 
198
  /**
199
- * Delete directory recursively
200
- *
201
- * @param string $path
202
- * @return Maged_Connect
203
- */
204
  public function delTree($path) {
205
  if (@is_dir($path)) {
206
  $entries = @scandir($path);
@@ -217,13 +238,13 @@ class Maged_Connect
217
  }
218
 
219
  /**
220
- * Run commands from Mage_Connect_Command
221
- *
222
- * @param string $command
223
- * @param array $options
224
- * @param array $params
225
- * @return
226
- */
227
  public function run($command, $options=array(), $params=array())
228
  {
229
  @set_time_limit(0);
@@ -257,16 +278,20 @@ class Maged_Connect
257
  }
258
  }
259
 
260
- public function setRemoteConfig($uri) #$host, $user, $password, $path='', $port=null)
 
 
 
 
 
 
261
  {
262
- #$uri = 'ftp://' . $user . ':' . $password . '@' . $host . (is_numeric($port) ? ':' . $port : '') . '/' . trim($path, '/') . '/';
263
- //$this->run('config-set', array(), array('remote_config', $uri));
264
- //$this->run('config-set', array('ftp'=>$uri), array('remote_config', $uri));
265
  $this->getConfig()->remote_config=$uri;
266
  return $this;
267
  }
268
 
269
  /**
 
270
  *
271
  * @param array $errors Error messages
272
  * @return Maged_Connect
@@ -277,7 +302,7 @@ class Maged_Connect
277
  $run = new Maged_Model_Connect_Request();
278
  if ($callback = $run->get('failure_callback')) {
279
  if (is_array($callback)) {
280
- call_user_func_array($callback, array($result));
281
  } else {
282
  echo $callback;
283
  }
@@ -290,8 +315,9 @@ class Maged_Connect
290
  /**
291
  * Run Mage_Connect_Command with html output console style
292
  *
293
- * @param array|Maged_Model $runParams command, options, params,
294
- * comment, success_callback, failure_callback
 
295
  */
296
  public function runHtmlConsole($runParams)
297
  {
@@ -318,6 +344,58 @@ class Maged_Connect
318
  }
319
 
320
  if (!$run->get('no-header')) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
321
  ?>
322
  <html><head><style type="text/css">
323
  body { margin:0px;
@@ -414,44 +492,17 @@ function clear_cache(callbacks)
414
  }
415
  </script>
416
  <?php
 
417
  }
418
- echo htmlspecialchars($run->get('comment'));
419
-
420
- if ($command = $run->get('command')) {
421
- $result = $this->run($command, $run->get('options'), $run->get('params'));
422
 
423
- if ($this->getFrontend()->hasErrors()) {
424
- echo "<br/>CONNECT ERROR: ";
425
- foreach ($this->getFrontend()->getErrors(false) as $error) {
426
- echo nl2br($error[1]);
427
- echo '<br/>';
428
- }
429
- }
430
- echo '<script type="text/javascript">';
431
- if ($this->getFrontend()->hasErrors()) {
432
- if ($callback = $run->get('failure_callback')) {
433
- if (is_array($callback)) {
434
- call_user_func_array($callback, array($result));
435
- } else {
436
- echo $callback;
437
- }
438
- }
439
- } else {
440
- if (!$run->get('no-footer')) {
441
- if ($callback = $run->get('success_callback')) {
442
- if (is_array($callback)) {
443
- call_user_func_array($callback, array($result));
444
- } else {
445
- echo $callback;
446
- }
447
- }
448
- }
449
- }
450
- echo '</script>';
451
- } else {
452
- $result = false;
453
- }
454
- if ($this->getFrontend()->getErrors() || !$run->get('no-footer')) {
455
  ?>
456
  <script type="text/javascript">
457
  if (parent && parent.disableInputs) {
@@ -460,8 +511,7 @@ if (parent && parent.disableInputs) {
460
  </script>
461
  </body></html>
462
  <?php
463
- $fe->setLogStream($oldLogStream);
464
  }
465
- return $result;
466
  }
467
  }
20
  *
21
  * @category Mage
22
  * @package Mage_Connect
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
55
  {
56
 
57
  /**
58
+ * Object of config
59
+ *
60
+ * @var Mage_Connect_Config
61
+ */
62
  protected $_config;
63
 
64
  /**
65
+ * Object of single config
66
+ *
67
+ * @var Mage_Connect_Singleconfig
68
+ */
69
  protected $_sconfig;
70
 
71
  /**
76
  protected $_frontend;
77
 
78
  /**
79
+ * Internal cache for command objects
80
+ *
81
+ * @var array
82
+ */
83
  protected $_cmdCache = array();
84
 
85
  /**
86
+ * Console Started flag
87
+ *
88
+ * @var boolean
89
+ */
90
+ protected $_consoleStarted = false;
91
+
92
+ /**
93
+ * Instance of class
94
+ *
95
+ * @var Maged_Connect
96
+ */
97
  static protected $_instance;
98
 
99
  /**
100
+ * Constructor loads Config, Cache Config and initializes Frontend
101
+ */
102
  public function __construct()
103
  {
104
  $this->getConfig();
107
  }
108
 
109
  /**
110
+ * Destructor, sends Console footer if Console started
111
+ */
112
+ public function __destruct()
113
+ {
114
+ if ($this->_consoleStarted) {
115
+ $this->_consoleFooter();
116
+ }
117
+ }
118
+
119
+ /**
120
+ * Initialize instance
121
+ *
122
+ * @return Maged_Connect
123
+ */
124
  public static function getInstance()
125
  {
126
  if (!self::$_instance) {
130
  }
131
 
132
  /**
133
+ * Retrieve object of config and set it to Mage_Connect_Command
134
+ *
135
+ * @return Mage_Connect_Config
136
+ */
137
  public function getConfig()
138
  {
139
  if (!$this->_config) {
152
  }
153
 
154
  /**
155
+ * Retrieve object of single config and set it to Mage_Connect_Command
156
+ *
157
+ * @param bool $reload
158
+ * @return Mage_Connect_Singleconfig
159
+ */
160
  public function getSingleConfig($reload = false)
161
  {
162
  if(!$this->_sconfig || $reload) {
163
+ $this->_sconfig = new Mage_Connect_Singleconfig(
164
+ $this->getConfig()->magento_root . DIRECTORY_SEPARATOR
165
+ . $this->getConfig()->downloader_path . DIRECTORY_SEPARATOR
166
+ . Mage_Connect_Singleconfig::DEFAULT_SCONFIG_FILENAME
167
+ );
168
  }
169
  Mage_Connect_Command::setSconfig($this->_sconfig);
170
  return $this->_sconfig;
172
  }
173
 
174
  /**
175
+ * Retrieve object of frontend and set it to Mage_Connect_Command
176
+ *
177
+ * @return Maged_Connect_Frontend
178
+ */
179
  public function getFrontend()
180
  {
181
  if (!$this->_frontend) {
186
  }
187
 
188
  /**
189
+ * Retrieve lof from frontend
190
+ *
191
+ * @return array
192
+ */
193
  public function getLog()
194
  {
195
  return $this->getFrontend()->getLog();
196
  }
197
 
198
  /**
199
+ * Retrieve output from frontend
200
+ *
201
+ * @return array
202
+ */
203
  public function getOutput()
204
  {
205
  return $this->getFrontend()->getOutput();
206
  }
207
 
208
  /**
209
+ * Clean registry
210
+ *
211
+ * @return Maged_Connect
212
+ */
213
  public function cleanSconfig()
214
  {
215
  $this->getSingleConfig()->clear();
217
  }
218
 
219
  /**
220
+ * Delete directory recursively
221
+ *
222
+ * @param string $path
223
+ * @return Maged_Connect
224
+ */
225
  public function delTree($path) {
226
  if (@is_dir($path)) {
227
  $entries = @scandir($path);
238
  }
239
 
240
  /**
241
+ * Run commands from Mage_Connect_Command
242
+ *
243
+ * @param string $command
244
+ * @param array $options
245
+ * @param array $params
246
+ * @return boolean|Mage_Connect_Error
247
+ */
248
  public function run($command, $options=array(), $params=array())
249
  {
250
  @set_time_limit(0);
278
  }
279
  }
280
 
281
+ /**
282
+ * Set remote Config by URI
283
+ *
284
+ * @param $uri
285
+ * @return Maged_Connect
286
+ */
287
+ public function setRemoteConfig($uri)
288
  {
 
 
 
289
  $this->getConfig()->remote_config=$uri;
290
  return $this;
291
  }
292
 
293
  /**
294
+ * Show Errors
295
  *
296
  * @param array $errors Error messages
297
  * @return Maged_Connect
302
  $run = new Maged_Model_Connect_Request();
303
  if ($callback = $run->get('failure_callback')) {
304
  if (is_array($callback)) {
305
+ call_user_func_array($callback, array($errors));
306
  } else {
307
  echo $callback;
308
  }
315
  /**
316
  * Run Mage_Connect_Command with html output console style
317
  *
318
+ * @throws Maged_Exception
319
+ * @param array|string|Maged_Model $runParams command, options, params, comment, success_callback, failure_callback
320
+ * @return bool|Mage_Connect_Error
321
  */
322
  public function runHtmlConsole($runParams)
323
  {
344
  }
345
 
346
  if (!$run->get('no-header')) {
347
+ $this->_consoleHeader();
348
+ }
349
+ echo htmlspecialchars($run->get('comment')).'<br/>';
350
+
351
+ if ($command = $run->get('command')) {
352
+ $result = $this->run($command, $run->get('options'), $run->get('params'));
353
+
354
+ if ($this->getFrontend()->hasErrors()) {
355
+ echo "<br/>CONNECT ERROR: ";
356
+ foreach ($this->getFrontend()->getErrors(false) as $error) {
357
+ echo nl2br($error[1]);
358
+ echo '<br/>';
359
+ }
360
+ }
361
+ echo '<script type="text/javascript">';
362
+ if ($this->getFrontend()->hasErrors()) {
363
+ if ($callback = $run->get('failure_callback')) {
364
+ if (is_array($callback)) {
365
+ call_user_func_array($callback, array($result));
366
+ } else {
367
+ echo $callback;
368
+ }
369
+ }
370
+ } else {
371
+ if (!$run->get('no-footer')) {
372
+ if ($callback = $run->get('success_callback')) {
373
+ if (is_array($callback)) {
374
+ call_user_func_array($callback, array($result));
375
+ } else {
376
+ echo $callback;
377
+ }
378
+ }
379
+ }
380
+ }
381
+ echo '</script>';
382
+ } else {
383
+ $result = false;
384
+ }
385
+ if ($this->getFrontend()->getErrors() || !$run->get('no-footer')) {
386
+ //$this->_consoleFooter();
387
+ $fe->setLogStream($oldLogStream);
388
+ }
389
+ return $result;
390
+ }
391
+
392
+ /**
393
+ * Show HTML Console Header
394
+ *
395
+ * @return void
396
+ */
397
+ protected function _consoleHeader() {
398
+ if (!$this->_consoleStarted) {
399
  ?>
400
  <html><head><style type="text/css">
401
  body { margin:0px;
492
  }
493
  </script>
494
  <?php
495
+ $this->_consoleStarted = true;
496
  }
497
+ }
 
 
 
498
 
499
+ /**
500
+ * Show HTML Console Footer
501
+ *
502
+ * @return void
503
+ */
504
+ protected function _consoleFooter() {
505
+ if ($this->_consoleStarted) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
506
  ?>
507
  <script type="text/javascript">
508
  if (parent && parent.disableInputs) {
511
  </script>
512
  </body></html>
513
  <?php
514
+ $this->_consoleStarted = false;
515
  }
 
516
  }
517
  }
downloader/Maged/Connect/Frontend.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_Connect
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
20
  *
21
  * @category Mage
22
  * @package Mage_Connect
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
downloader/Maged/Controller.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_Connect
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
@@ -492,7 +492,6 @@ final class Maged_Controller
492
  self::singleton()->dispatch();
493
  } catch (Exception $e) {
494
  echo $e->getMessage();
495
- //echo self::singleton()->view()->set('exception', $e)->template("exception.phtml");
496
  }
497
  }
498
 
@@ -597,7 +596,7 @@ final class Maged_Controller
597
  if (is_null($model)) {
598
  $class = 'Maged_Model';
599
  } else {
600
- $class = 'Maged_Model_'.str_replace(' ', '_', ucwords(str_replace('_', ' ', $model)));
601
  if (!class_exists($class, false)) {
602
  include_once str_replace('_', DIRECTORY_SEPARATOR, $class).'.php';
603
  }
@@ -884,6 +883,31 @@ final class Maged_Controller
884
  @file_put_contents($this->_getMaintenanceFilePath(), 'maintenance');
885
  }
886
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
887
  }
888
 
889
  /**
@@ -967,11 +991,103 @@ final class Maged_Controller
967
  {
968
  return array(
969
  'major' => '1',
970
- 'minor' => '5',
971
  'revision' => '0',
972
  'patch' => '0',
973
  'stability' => '',
974
  'number' => '',
975
  );
976
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
977
  }
20
  *
21
  * @category Mage
22
  * @package Mage_Connect
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
492
  self::singleton()->dispatch();
493
  } catch (Exception $e) {
494
  echo $e->getMessage();
 
495
  }
496
  }
497
 
596
  if (is_null($model)) {
597
  $class = 'Maged_Model';
598
  } else {
599
+ $class = 'Maged_Model_' . str_replace(' ', '_', ucwords(str_replace('_', ' ', $model)));
600
  if (!class_exists($class, false)) {
601
  include_once str_replace('_', DIRECTORY_SEPARATOR, $class).'.php';
602
  }
883
  @file_put_contents($this->_getMaintenanceFilePath(), 'maintenance');
884
  }
885
  }
886
+
887
+ if (!empty($_GET['archive_type'])) {
888
+
889
+ $backupName = $_GET['backup_name'];
890
+ $connect = $this->model('connect', true)->connect();
891
+ $isSuccess = true;
892
+
893
+ if (!preg_match('/^[a-zA-Z0-9\ ]{0,50}$/', $backupName)) {
894
+ $connect->runHtmlConsole('Please use only letters (a-z or A-Z), numbers (0-9) or space in '
895
+ . 'Backup Name field. Other characters are not allowed.');
896
+ $isSuccess = false;
897
+ }
898
+
899
+ if ($isSuccess) {
900
+ $isSuccess = $this->_createBackup($_GET['archive_type'], $_GET['backup_name']);
901
+ }
902
+
903
+ if (!$isSuccess) {
904
+ $this->endInstall();
905
+ $this->cleanCache();
906
+ throw new Mage_Exception(
907
+ 'The installation process has been canceled because of the backup creation error'
908
+ );
909
+ }
910
+ }
911
  }
912
 
913
  /**
991
  {
992
  return array(
993
  'major' => '1',
994
+ 'minor' => '7',
995
  'revision' => '0',
996
  'patch' => '0',
997
  'stability' => '',
998
  'number' => '',
999
  );
1000
  }
1001
+
1002
+ /**
1003
+ * Create Backup
1004
+ *
1005
+ * @param string $archiveType
1006
+ * @param string $archiveName
1007
+ * @return bool
1008
+ */
1009
+ protected function _createBackup($archiveType, $archiveName){
1010
+ /** @var $connect Maged_Connect */
1011
+ $connect = $this->model('connect', true)->connect();
1012
+ $connect->runHtmlConsole('Creating backup...');
1013
+
1014
+ $isSuccess = false;
1015
+
1016
+ try {
1017
+ $type = $this->_getBackupTypeByCode($archiveType);
1018
+
1019
+ $backupManager = Mage_Backup::getBackupInstance($type)
1020
+ ->setBackupExtension(Mage::helper('backup')->getExtensionByType($type))
1021
+ ->setTime(time())
1022
+ ->setName($archiveName)
1023
+ ->setBackupsDir(Mage::helper('backup')->getBackupsDir());
1024
+
1025
+ Mage::register('backup_manager', $backupManager);
1026
+
1027
+ if ($type != Mage_Backup_Helper_Data::TYPE_DB) {
1028
+ $backupManager->setRootDir(Mage::getBaseDir())
1029
+ ->addIgnorePaths(Mage::helper('backup')->getBackupIgnorePaths());
1030
+ }
1031
+ $backupManager->create();
1032
+ $connect->runHtmlConsole(
1033
+ $this->_getCreateBackupSuccessMessageByType($type)
1034
+ );
1035
+ $isSuccess = true;
1036
+ } catch (Mage_Backup_Exception_NotEnoughFreeSpace $e) {
1037
+ $connect->runHtmlConsole('Not enough free space to create backup.');
1038
+ Mage::logException($e);
1039
+ } catch (Mage_Backup_Exception_NotEnoughPermissions $e) {
1040
+ $connect->runHtmlConsole('Not enough permissions to create backup.');
1041
+ Mage::logException($e);
1042
+ } catch (Exception $e) {
1043
+ $connect->runHtmlConsole('An error occurred while creating the backup.');
1044
+ Mage::logException($e);
1045
+ }
1046
+
1047
+ return $isSuccess;
1048
+ }
1049
+
1050
+ /**
1051
+ * Retrieve Backup Type by Code
1052
+ *
1053
+ * @param int $code
1054
+ * @return string
1055
+ */
1056
+ protected function _getBackupTypeByCode($code)
1057
+ {
1058
+ $typeMap = array(
1059
+ 1 => Mage_Backup_Helper_Data::TYPE_DB,
1060
+ 2 => Mage_Backup_Helper_Data::TYPE_SYSTEM_SNAPSHOT,
1061
+ 3 => Mage_Backup_Helper_Data::TYPE_SNAPSHOT_WITHOUT_MEDIA,
1062
+ 4 => Mage_Backup_Helper_Data::TYPE_MEDIA
1063
+ );
1064
+
1065
+ if (!isset($typeMap[$code])) {
1066
+ Mage::throwException('Unknown backup type');
1067
+ }
1068
+
1069
+ return $typeMap[$code];
1070
+ }
1071
+
1072
+ /**
1073
+ * Get backup create success message by backup type
1074
+ *
1075
+ * @param string $type
1076
+ * @return string
1077
+ */
1078
+ protected function _getCreateBackupSuccessMessageByType($type)
1079
+ {
1080
+ $messagesMap = array(
1081
+ Mage_Backup_Helper_Data::TYPE_SYSTEM_SNAPSHOT => 'System backup has been created',
1082
+ Mage_Backup_Helper_Data::TYPE_SNAPSHOT_WITHOUT_MEDIA => 'System (excluding Media) backup has been created',
1083
+ Mage_Backup_Helper_Data::TYPE_MEDIA => 'Database and media backup has been created',
1084
+ Mage_Backup_Helper_Data::TYPE_DB => 'Database backup has been created'
1085
+ );
1086
+
1087
+ if (!isset($messagesMap[$type])) {
1088
+ return '';
1089
+ }
1090
+
1091
+ return $messagesMap[$type];
1092
+ }
1093
  }
downloader/Maged/Exception.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_Connect
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
20
  *
21
  * @category Mage
22
  * @package Mage_Connect
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
downloader/Maged/Model.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_Connect
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
20
  *
21
  * @category Mage
22
  * @package Mage_Connect
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
downloader/Maged/Model/Config.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_Connect
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
20
  *
21
  * @category Mage
22
  * @package Mage_Connect
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
downloader/Maged/Model/Config/Abstract.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_Connect
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
20
  *
21
  * @category Mage
22
  * @package Mage_Connect
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
downloader/Maged/Model/Config/Community.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_Connect
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
20
  *
21
  * @category Mage
22
  * @package Mage_Connect
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
downloader/Maged/Model/Config/Interface.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_Connect
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
20
  *
21
  * @category Mage
22
  * @package Mage_Connect
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
downloader/Maged/Model/Connect.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_Connect
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
20
  *
21
  * @category Mage
22
  * @package Mage_Connect
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
downloader/Maged/Model/Connect/Request.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_Connect
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
20
  *
21
  * @category Mage
22
  * @package Mage_Connect
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
downloader/Maged/Model/Dowloader.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_Connect
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
20
  *
21
  * @category Mage
22
  * @package Mage_Connect
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
downloader/Maged/Model/Session.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_Connect
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
20
  *
21
  * @category Mage
22
  * @package Mage_Connect
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
downloader/Maged/View.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_Connect
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
20
  *
21
  * @category Mage
22
  * @package Mage_Connect
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
downloader/favicon.ico ADDED
Binary file
downloader/index.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_Connect
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
20
  *
21
  * @category Mage
22
  * @package Mage_Connect
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
downloader/lib/Mage/Archive.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_Archive
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
@@ -84,7 +84,7 @@ class Mage_Archive
84
  } else {
85
  $format = self::DEFAULT_ARCHIVER;
86
  }
87
- $class = 'Mage_Archive_'.ucfirst($format);
88
  $this->_archiver = new $class();
89
  return $this->_archiver;
90
  }
@@ -157,12 +157,13 @@ class Mage_Archive
157
  if ($i == 0) {
158
  $packed = rtrim($destination, DS) . DS;
159
  } else {
160
- $packed = rtrim($destination, DS) . DS . '~tmp-'. microtime(true) . $archivers[$i-1] . '.' . $archivers[$i-1];
 
161
  }
162
  $source = $this->_getArchiver($archivers[$i])->unpack($source, $packed);
163
-
164
  //var_dump($packed, $source);
165
-
166
  if ($clearInterm && $interimSource && $i >= 0) {
167
  unlink($interimSource);
168
  }
@@ -218,5 +219,4 @@ class Mage_Archive
218
  }
219
  return false;
220
  }
221
-
222
  }
20
  *
21
  * @category Mage
22
  * @package Mage_Archive
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
84
  } else {
85
  $format = self::DEFAULT_ARCHIVER;
86
  }
87
+ $class = 'Mage_Archive_' . ucfirst($format);
88
  $this->_archiver = new $class();
89
  return $this->_archiver;
90
  }
157
  if ($i == 0) {
158
  $packed = rtrim($destination, DS) . DS;
159
  } else {
160
+ $packed = rtrim($destination, DS) . DS . '~tmp-'. microtime(true) . $archivers[$i-1] . '.'
161
+ . $archivers[$i-1];
162
  }
163
  $source = $this->_getArchiver($archivers[$i])->unpack($source, $packed);
164
+
165
  //var_dump($packed, $source);
166
+
167
  if ($clearInterm && $interimSource && $i >= 0) {
168
  unlink($interimSource);
169
  }
219
  }
220
  return false;
221
  }
 
222
  }
downloader/lib/Mage/Archive/Abstract.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_Archive
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
@@ -34,14 +34,16 @@
34
  class Mage_Archive_Abstract
35
  {
36
  /**
37
- * Write data to file. If file can't be opened,
38
  *
39
  * @param string $destination
40
  * @param string $data
41
  * @return boolean
 
42
  */
43
  protected function _writeFile($destination, $data)
44
  {
 
45
  if(false === file_put_contents($destination, $data)) {
46
  throw new Mage_Exception("Can't write to file: " . $destination);
47
  }
@@ -53,6 +55,7 @@ class Mage_Archive_Abstract
53
  *
54
  * @param string $source
55
  * @return string
 
56
  */
57
  protected function _readFile($source)
58
  {
@@ -70,7 +73,8 @@ class Mage_Archive_Abstract
70
  * Get file name from source (URI) without last extension.
71
  *
72
  * @param string $source
73
- * @return string
 
74
  */
75
  public function getFilename($source, $withExtension=false)
76
  {
@@ -80,5 +84,4 @@ class Mage_Archive_Abstract
80
  }
81
  return $file;
82
  }
83
-
84
  }
20
  *
21
  * @category Mage
22
  * @package Mage_Archive
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
34
  class Mage_Archive_Abstract
35
  {
36
  /**
37
+ * Write data to file. If file can't be opened - throw exception
38
  *
39
  * @param string $destination
40
  * @param string $data
41
  * @return boolean
42
+ * @throws Mage_Exception
43
  */
44
  protected function _writeFile($destination, $data)
45
  {
46
+ $destination = trim($destination);
47
  if(false === file_put_contents($destination, $data)) {
48
  throw new Mage_Exception("Can't write to file: " . $destination);
49
  }
55
  *
56
  * @param string $source
57
  * @return string
58
+ * @throws Mage_Exception
59
  */
60
  protected function _readFile($source)
61
  {
73
  * Get file name from source (URI) without last extension.
74
  *
75
  * @param string $source
76
+ * @param bool $withExtension
77
+ * @return mixed|string
78
  */
79
  public function getFilename($source, $withExtension=false)
80
  {
84
  }
85
  return $file;
86
  }
 
87
  }
downloader/lib/Mage/Archive/Bz.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_Archive
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
@@ -43,9 +43,19 @@ class Mage_Archive_Bz extends Mage_Archive_Abstract implements Mage_Archive_Inte
43
  */
44
  public function pack($source, $destination)
45
  {
46
- $data = $this->_readFile($source);
47
- $bzData = bzcompress($data, 9);
48
- $this->_writeFile($destination, $bzData);
 
 
 
 
 
 
 
 
 
 
49
  return $destination;
50
  }
51
 
@@ -58,21 +68,21 @@ class Mage_Archive_Bz extends Mage_Archive_Abstract implements Mage_Archive_Inte
58
  */
59
  public function unpack($source, $destination)
60
  {
61
- $data = '';
62
- $bzPointer = bzopen($source, 'r' );
63
- if (empty($bzPointer)) {
64
- throw new Exception('Can\'t open BZ archive : ' . $source);
65
- }
66
- while (!feof($bzPointer)) {
67
- $data .= bzread($bzPointer, 131072);
68
- }
69
- bzclose($bzPointer);
70
  if (is_dir($destination)) {
71
  $file = $this->getFilename($source);
72
  $destination = $destination . $file;
73
  }
74
- echo $destination;
75
- $this->_writeFile($destination, $data);
 
 
 
 
 
 
 
 
 
76
  return $destination;
77
  }
78
 
20
  *
21
  * @category Mage
22
  * @package Mage_Archive
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
43
  */
44
  public function pack($source, $destination)
45
  {
46
+ $fileReader = new Mage_Archive_Helper_File($source);
47
+ $fileReader->open('r');
48
+
49
+ $archiveWriter = new Mage_Archive_Helper_File_Bz($destination);
50
+ $archiveWriter->open('w');
51
+
52
+ while (!$fileReader->eof()) {
53
+ $archiveWriter->write($fileReader->read());
54
+ }
55
+
56
+ $fileReader->close();
57
+ $archiveWriter->close();
58
+
59
  return $destination;
60
  }
61
 
68
  */
69
  public function unpack($source, $destination)
70
  {
 
 
 
 
 
 
 
 
 
71
  if (is_dir($destination)) {
72
  $file = $this->getFilename($source);
73
  $destination = $destination . $file;
74
  }
75
+
76
+ $archiveReader = new Mage_Archive_Helper_File_Bz($source);
77
+ $archiveReader->open('r');
78
+
79
+ $fileWriter = new Mage_Archive_Helper_File($destination);
80
+ $fileWriter->open('w');
81
+
82
+ while (!$archiveReader->eof()) {
83
+ $fileWriter->write($archiveReader->read());
84
+ }
85
+
86
  return $destination;
87
  }
88
 
downloader/lib/Mage/Archive/Gz.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_Archive
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
@@ -42,9 +42,19 @@ class Mage_Archive_Gz extends Mage_Archive_Abstract implements Mage_Archive_Inte
42
  */
43
  public function pack($source, $destination)
44
  {
45
- $data = $this->_readFile($source);
46
- $gzData = gzencode($data, 9);
47
- $this->_writeFile($destination, $gzData);
 
 
 
 
 
 
 
 
 
 
48
  return $destination;
49
  }
50
 
@@ -57,21 +67,21 @@ class Mage_Archive_Gz extends Mage_Archive_Abstract implements Mage_Archive_Inte
57
  */
58
  public function unpack($source, $destination)
59
  {
60
- $gzPointer = gzopen($source, 'r' );
61
- if (empty($gzPointer)) {
62
- throw new Mage_Exception('Can\'t open GZ archive : ' . $source);
63
- }
64
- $data = '';
65
- while (!gzeof($gzPointer)) {
66
- $data .= gzread($gzPointer, 131072);
67
- }
68
- gzclose($gzPointer);
69
  if (is_dir($destination)) {
70
  $file = $this->getFilename($source);
71
  $destination = $destination . $file;
72
  }
73
- $this->_writeFile($destination, $data);
 
 
 
 
 
 
 
 
 
 
74
  return $destination;
75
  }
76
-
77
  }
20
  *
21
  * @category Mage
22
  * @package Mage_Archive
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
42
  */
43
  public function pack($source, $destination)
44
  {
45
+ $fileReader = new Mage_Archive_Helper_File($source);
46
+ $fileReader->open('r');
47
+
48
+ $archiveWriter = new Mage_Archive_Helper_File_Gz($destination);
49
+ $archiveWriter->open('wb9');
50
+
51
+ while (!$fileReader->eof()) {
52
+ $archiveWriter->write($fileReader->read());
53
+ }
54
+
55
+ $fileReader->close();
56
+ $archiveWriter->close();
57
+
58
  return $destination;
59
  }
60
 
67
  */
68
  public function unpack($source, $destination)
69
  {
 
 
 
 
 
 
 
 
 
70
  if (is_dir($destination)) {
71
  $file = $this->getFilename($source);
72
  $destination = $destination . $file;
73
  }
74
+
75
+ $archiveReader = new Mage_Archive_Helper_File_Gz($source);
76
+ $archiveReader->open('r');
77
+
78
+ $fileWriter = new Mage_Archive_Helper_File($destination);
79
+ $fileWriter->open('w');
80
+
81
+ while (!$archiveReader->eof()) {
82
+ $fileWriter->write($archiveReader->read());
83
+ }
84
+
85
  return $destination;
86
  }
 
87
  }
downloader/lib/Mage/Archive/Helper/File.php ADDED
@@ -0,0 +1,274 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Archive
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Helper class that simplifies files stream reading and writing
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Archive
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Archive_Helper_File
35
+ {
36
+ /**
37
+ * Full path to directory where file located
38
+ *
39
+ * @var string
40
+ */
41
+ protected $_fileLocation;
42
+
43
+ /**
44
+ * File name
45
+ *
46
+ * @var string
47
+ */
48
+ protected $_fileName;
49
+
50
+ /**
51
+ * Full path (directory + filename) to file
52
+ *
53
+ * @var string
54
+ */
55
+ protected $_filePath;
56
+
57
+ /**
58
+ * File permissions that will be set if file opened in write mode
59
+ *
60
+ * @var int
61
+ */
62
+ protected $_chmod;
63
+
64
+ /**
65
+ * File handler
66
+ *
67
+ * @var pointer
68
+ */
69
+ protected $_fileHandler;
70
+
71
+ /**
72
+ * Set file path via constructor
73
+ *
74
+ * @param string $filePath
75
+ */
76
+ public function __construct($filePath)
77
+ {
78
+ $pathInfo = pathinfo($filePath);
79
+
80
+ $this->_filePath = $filePath;
81
+ $this->_fileLocation = isset($pathInfo['dirname']) ? $pathInfo['dirname'] : '';
82
+ $this->_fileName = isset($pathInfo['basename']) ? $pathInfo['basename'] : '';
83
+ }
84
+
85
+ /**
86
+ * Close file if it's not closed before object destruction
87
+ */
88
+ public function __destruct()
89
+ {
90
+ if ($this->_fileHandler) {
91
+ $this->_close();
92
+ }
93
+ }
94
+
95
+ /**
96
+ * Open file
97
+ *
98
+ * @param string $mode
99
+ * @param int $chmod
100
+ * @throws Mage_Exception
101
+ */
102
+ public function open($mode = 'w+', $chmod = 0666)
103
+ {
104
+ if ($this->_isWritableMode($mode)) {
105
+ if (!is_writable($this->_fileLocation)) {
106
+ throw new Mage_Exception('Permission denied to write to ' . $this->_fileLocation);
107
+ }
108
+
109
+ if (is_file($this->_filePath) && !is_writable($this->_filePath)) {
110
+ throw new Mage_Exception("Can't open file " . $this->_fileName . " for writing. Permission denied.");
111
+ }
112
+ }
113
+
114
+ if ($this->_isReadableMode($mode) && (!is_file($this->_filePath) || !is_readable($this->_filePath))) {
115
+ if (!is_file($this->_filePath)) {
116
+ throw new Mage_Exception('File ' . $this->_filePath . ' does not exist');
117
+ }
118
+
119
+ if (!is_readable($this->_filePath)) {
120
+ throw new Mage_Exception('Permission denied to read file ' . $this->_filePath);
121
+ }
122
+ }
123
+
124
+ $this->_open($mode);
125
+
126
+ $this->_chmod = $chmod;
127
+ }
128
+
129
+ /**
130
+ * Write data to file
131
+ *
132
+ * @param string $data
133
+ */
134
+ public function write($data)
135
+ {
136
+ $this->_checkFileOpened();
137
+ $this->_write($data);
138
+ }
139
+
140
+ /**
141
+ * Read data from file
142
+ *
143
+ * @param int $length
144
+ * @return string|boolean
145
+ */
146
+ public function read($length = 4096)
147
+ {
148
+ $data = false;
149
+ $this->_checkFileOpened();
150
+ if ($length > 0) {
151
+ $data = $this->_read($length);
152
+ }
153
+
154
+ return $data;
155
+ }
156
+
157
+ /**
158
+ * Check whether end of file reached
159
+ *
160
+ * @return boolean
161
+ */
162
+ public function eof()
163
+ {
164
+ $this->_checkFileOpened();
165
+ return $this->_eof();
166
+ }
167
+
168
+ /**
169
+ * Close file
170
+ */
171
+ public function close()
172
+ {
173
+ $this->_checkFileOpened();
174
+ $this->_close();
175
+ $this->_fileHandler = false;
176
+ @chmod($this->_filePath, $this->_chmod);
177
+ }
178
+
179
+ /**
180
+ * Implementation of file opening
181
+ *
182
+ * @param string $mode
183
+ * @throws Mage_Exception
184
+ */
185
+ protected function _open($mode)
186
+ {
187
+ $this->_fileHandler = @fopen($this->_filePath, $mode);
188
+
189
+ if (false === $this->_fileHandler) {
190
+ throw new Mage_Exception('Failed to open file ' . $this->_filePath);
191
+ }
192
+ }
193
+
194
+ /**
195
+ * Implementation of writing data to file
196
+ *
197
+ * @param string $data
198
+ * @throws Mage_Exception
199
+ */
200
+ protected function _write($data)
201
+ {
202
+ $result = @fwrite($this->_fileHandler, $data);
203
+
204
+ if (false === $result) {
205
+ throw new Mage_Exception('Failed to write data to ' . $this->_filePath);
206
+ }
207
+ }
208
+
209
+ /**
210
+ * Implementation of file reading
211
+ *
212
+ * @param int $length
213
+ * @throws Mage_Exception
214
+ */
215
+ protected function _read($length)
216
+ {
217
+ $result = fread($this->_fileHandler, $length);
218
+
219
+ if (false === $result) {
220
+ throw new Mage_Exception('Failed to read data from ' . $this->_filePath);
221
+ }
222
+
223
+ return $result;
224
+ }
225
+
226
+ /**
227
+ * Implementation of EOF indicator
228
+ *
229
+ * @return boolean
230
+ */
231
+ protected function _eof()
232
+ {
233
+ return feof($this->_fileHandler);
234
+ }
235
+
236
+ /**
237
+ * Implementation of file closing
238
+ */
239
+ protected function _close()
240
+ {
241
+ fclose($this->_fileHandler);
242
+ }
243
+
244
+ /**
245
+ * Check whether requested mode is writable mode
246
+ *
247
+ * @param string $mode
248
+ */
249
+ protected function _isWritableMode($mode)
250
+ {
251
+ return preg_match('/(^[waxc])|(\+$)/', $mode);
252
+ }
253
+
254
+ /**
255
+ * Check whether requested mode is readable mode
256
+ *
257
+ * @param string $mode
258
+ */
259
+ protected function _isReadableMode($mode) {
260
+ return !$this->_isWritableMode($mode);
261
+ }
262
+
263
+ /**
264
+ * Check whether file is opened
265
+ *
266
+ * @throws Mage_Exception
267
+ */
268
+ protected function _checkFileOpened()
269
+ {
270
+ if (!$this->_fileHandler) {
271
+ throw new Mage_Exception('File not opened');
272
+ }
273
+ }
274
+ }
downloader/lib/Mage/Archive/Helper/File/Bz.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Archive
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Helper class that simplifies bz2 files stream reading and writing
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Archive
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Archive_Helper_File_Bz extends Mage_Archive_Helper_File
35
+ {
36
+ /**
37
+ * Open bz archive file
38
+ *
39
+ * @throws Mage_Exception
40
+ * @param string $mode
41
+ */
42
+ protected function _open($mode)
43
+ {
44
+ $this->_fileHandler = @bzopen($this->_filePath, $mode);
45
+
46
+ if (false === $this->_fileHandler) {
47
+ throw new Mage_Exception('Failed to open file ' . $this->_filePath);
48
+ }
49
+ }
50
+
51
+ /**
52
+ * Write data to bz archive
53
+ *
54
+ * @throws Mage_Exception
55
+ * @param $data
56
+ */
57
+ protected function _write($data)
58
+ {
59
+ $result = @bzwrite($this->_fileHandler, $data);
60
+
61
+ if (false === $result) {
62
+ throw new Mage_Exception('Failed to write data to ' . $this->_filePath);
63
+ }
64
+ }
65
+
66
+ /**
67
+ * Read data from bz archive
68
+ *
69
+ * @throws Mage_Exception
70
+ * @param int $length
71
+ * @return string
72
+ */
73
+ protected function _read($length)
74
+ {
75
+ $data = bzread($this->_fileHandler, $length);
76
+
77
+ if (false === $data) {
78
+ throw new Mage_Exception('Failed to read data from ' . $this->_filePath);
79
+ }
80
+
81
+ return $data;
82
+ }
83
+
84
+ /**
85
+ * Close bz archive
86
+ */
87
+ protected function _close()
88
+ {
89
+ bzclose($this->_fileHandler);
90
+ }
91
+ }
92
+
downloader/lib/Mage/Archive/Helper/File/Gz.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Archive
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Helper class that simplifies gz files stream reading and writing
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Archive
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Archive_Helper_File_Gz extends Mage_Archive_Helper_File
35
+ {
36
+ /**
37
+ * @see Mage_Archive_Helper_File::_open()
38
+ */
39
+ protected function _open($mode)
40
+ {
41
+ $this->_fileHandler = @gzopen($this->_filePath, $mode);
42
+
43
+ if (false === $this->_fileHandler) {
44
+ throw new Mage_Exception('Failed to open file ' . $this->_filePath);
45
+ }
46
+ }
47
+
48
+ /**
49
+ * @see Mage_Archive_Helper_File::_write()
50
+ */
51
+ protected function _write($data)
52
+ {
53
+ $result = @gzwrite($this->_fileHandler, $data);
54
+
55
+ if (empty($result) && !empty($data)) {
56
+ throw new Mage_Exception('Failed to write data to ' . $this->_filePath);
57
+ }
58
+ }
59
+
60
+ /**
61
+ * @see Mage_Archive_Helper_File::_read()
62
+ */
63
+ protected function _read($length)
64
+ {
65
+ return gzread($this->_fileHandler, $length);
66
+ }
67
+
68
+ /**
69
+ * @see Mage_Archive_Helper_File::_eof()
70
+ */
71
+ protected function _eof()
72
+ {
73
+ return gzeof($this->_fileHandler);
74
+ }
75
+
76
+ /**
77
+ * @see Mage_Archive_Helper_File::_close()
78
+ */
79
+ protected function _close()
80
+ {
81
+ gzclose($this->_fileHandler);
82
+ }
83
+ }
downloader/lib/Mage/Archive/Interface.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_Archive
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
20
  *
21
  * @category Mage
22
  * @package Mage_Archive
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
downloader/lib/Mage/Archive/Tar.php CHANGED
<
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_Archive
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
@@ -34,9 +34,11 @@
34
  class Mage_Archive_Tar extends Mage_Archive_Abstract implements Mage_Archive_Interface
35
  {
36
  /**
37
- * Constant is used for parse tar's header.
 
 
38
  */
39
- const FORMAT_PARSE_HEADER = 'a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor/a155prefix/a12closer';
40
 
41
  /**
42
  * Keep file or directory for packing.
@@ -60,6 +62,122 @@ class Mage_Archive_Tar extends Mage_Archive_Abstract implements Mage_Archive_Int
60
  */
61
  protected $_skipRoot;
62