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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  /**
64
  * Set option that define ability skip first catalog level.
65
  *
@@ -80,7 +198,19 @@ class Mage_Archive_Tar extends Mage_Archive_Abstract implements Mage_Archive_Int
80
  */
81
  protected function _setCurrentFile($file)
82
  {
83
- $this->_currentFile = $file .((is_dir($file) && substr($file, -1)!=DS)?DS:'');
 
 
 
 
 
 
 
 
 
 
 
 
84
  return $this;
85
  }
86
 
@@ -124,6 +254,7 @@ class Mage_Archive_Tar extends Mage_Archive_Abstract implements Mage_Archive_Int
124
  * Walk through directory and add to tar file or directory.
125
  * Result is packed string on TAR format.
126
  *
 
127
  * @param boolean $skipRoot
128
  * @return string
129
  */
@@ -154,10 +285,74 @@ class Mage_Archive_Tar extends Mage_Archive_Abstract implements Mage_Archive_Int
154
  return $tarData;
155
  }
156
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  /**
158
  * Compose header for current file in TAR format.
159
  * If length of file's name greater 100 characters,
160
- * method breaks header to two pieces. First conatins
161
  * header and data with long name. Second contain only header.
162
  *
163
  * @param boolean $long
@@ -178,14 +373,16 @@ class Mage_Archive_Tar extends Mage_Archive_Abstract implements Mage_Archive_Int
178
  }
179
  $header = array();
180
  $header['100-name'] = $long?'././@LongLink':substr($nameFile, 0, 100);
181
- $header['8-mode'] = $long?' ':str_pad(substr(sprintf("%07o", $infoFile['mode']),-4), 6, '0', STR_PAD_LEFT);
 
182
  $header['8-uid'] = $long || $infoFile['uid']==0?"\0\0\0\0\0\0\0":sprintf("%07o", $infoFile['uid']);
183
  $header['8-gid'] = $long || $infoFile['gid']==0?"\0\0\0\0\0\0\0":sprintf("%07o", $infoFile['gid']);
184
- $header['12-size'] = $long?sprintf("%011o", strlen($nameFile)):sprintf("%011o", is_dir($file) ? 0 : filesize($file));
 
185
  $header['12-mtime'] = $long?'00000000000':sprintf("%011o", $infoFile['mtime']);
186
  $header['8-check'] = sprintf('% 8s', '');
187
- $header['1-type'] = $long?'L':(is_link($file) ? 2 : is_dir ($file) ? 5 : 0);
188
- $header['100-symlink'] = is_link($file) == 2 ? readlink($item) : '';
189
  $header['6-magic'] = 'ustar ';
190
  $header['2-version'] = ' ';
191
  $a=function_exists('posix_getpwuid')?posix_getpwuid (fileowner($file)):array('name'=>'');
@@ -219,38 +416,63 @@ class Mage_Archive_Tar extends Mage_Archive_Abstract implements Mage_Archive_Int
219
  *
220
  * @param string $destination path to file is unpacked
221
  * @return array list of files
 
222
  */
223
  protected function _unpackCurrentTar($destination)
224
  {
225
- $file = $this->_getCurrentFile();
226
- $pointer = fopen($file, 'r');
227
- if (empty($pointer)) {
228
- throw new Mage_Exception('Can\'t open file: ' . $file);
229
- }
230
  $list = array();
231
- while (!feof($pointer)) {
232
- $header = $this->_parseHeader($pointer);
233
- if ($header) {
234
- $currentFile = $destination . $header['name'];
235
- if ($header['type']=='5' && @mkdir($currentFile, 0777, true)) {
236
- $list[] = $currentFile . DS;
237
- } elseif (in_array($header['type'], array("0",chr(0), ''))) {
238
- $dirname = dirname($currentFile);
239
- if(!file_exists($dirname)) {
240
- @mkdir($dirname, 0777, true);
 
 
 
 
 
 
 
 
241
  }
242
- $this->_writeFile($currentFile, $header['data']);
243
- $list[] = $currentFile;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
244
  }
245
  }
246
  }
247
- fclose($pointer);
248
  return $list;
249
  }
250
 
251
  /**
252
  * Get header from TAR string and unpacked it by format.
253
  *
 
254
  * @param resource $pointer
255
  * @return string
256
  */
@@ -262,10 +484,9 @@ class Mage_Archive_Tar extends Mage_Archive_Abstract implements Mage_Archive_Int
262
  return false;
263
  }
264
 
265
- $fmt = self::FORMAT_PARSE_HEADER;
266
  $header = unpack ($fmt, $firstLine);
267
 
268
-
269
  $header['mode']=$header['mode']+0;
270
  $header['uid']=octdec($header['uid']);
271
  $header['gid']=octdec($header['gid']);
@@ -284,7 +505,7 @@ class Mage_Archive_Tar extends Mage_Archive_Abstract implements Mage_Archive_Int
284
  }
285
 
286
  $isUstar = 'ustar' == strtolower(substr($header['magic'], 0, 5));
287
-
288
  $checksumOk = $header['checksum'] == $checksum;
289
  if (isset($header['name']) && $checksumOk) {
290
  if ($header['name'] == '././@LongLink' && $header['type'] == 'L') {
@@ -304,6 +525,90 @@ class Mage_Archive_Tar extends Mage_Archive_Abstract implements Mage_Archive_Int
304
  return false;
305
  }
306
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
307
  /**
308
  * Pack file to TAR (Tape Archiver).
309
  *
@@ -312,14 +617,18 @@ class Mage_Archive_Tar extends Mage_Archive_Abstract implements Mage_Archive_Int
312
  * @param boolean $skipRoot
313
  * @return string
314
  */
315
- public function pack($source, $destination, $skipRoot=false)
316
  {
317
  $this->_setSkipRoot($skipRoot);
318
  $source = realpath($source);
319
  $tarData = $this->_setCurrentPath($source)
320
- ->_setCurrentFile($source)
321
- ->_packToTar($skipRoot);
322
- $this->_writeFile($destination, $tarData);
 
 
 
 
323
  return $destination;
324
  }
325
 
@@ -332,13 +641,13 @@ class Mage_Archive_Tar extends Mage_Archive_Abstract implements Mage_Archive_Int
332
  */
333
  public function unpack($source, $destination)
334
  {
335
- $tempFile = $destination . DS . '~tmp-'.microtime(true).'.tar';
336
- $data = $this->_readFile($source);
337
- $this->_writeFile($tempFile, $data);
338
- $this->_setCurrentFile($tempFile)
339
- ->_setCurrentPath($tempFile)
340
- ->_unpackCurrentTar($destination);
341
- unlink($tempFile);
342
  return $destination;
343
  }
344
 
@@ -352,21 +661,28 @@ class Mage_Archive_Tar extends Mage_Archive_Abstract implements Mage_Archive_Int
352
  */
353
  public function extract($file, $source, $destination)
354
  {
355
- $pointer = fopen($source, 'r');
356
- if (empty($pointer)) {
357
- throw new Mage_Exception('Can\'t open file: '.$source);
358
- }
359
- $list = array();
360
  $extractedFile = '';
361
- while (!feof($pointer)) {
362
- $header = $this->_parseHeader($pointer);
 
363
  if ($header['name'] == $file) {
364
  $extractedFile = $destination . basename($header['name']);
365
- $this->_writeFile($extractedFile, $header['data']);
366
  break;
367
  }
 
 
 
 
 
 
368
  }
369
- fclose($pointer);
 
370
  return $extractedFile;
371
  }
372
  }
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_Tar extends Mage_Archive_Abstract implements Mage_Archive_Interface
35
  {
36
  /**
37
+ * Tar block size
38
+ *
39
+ * @const int
40
  */
41
+ const TAR_BLOCK_SIZE = 512;
42
 
43
  /**
44
  * Keep file or directory for packing.
62
  */
63
  protected $_skipRoot;
64
 
65
+ /**
66
+ * Tarball data writer
67
+ *
68
+ * @var Mage_Archive_Helper_File
69
+ */
70
+ protected $_writer;
71
+
72
+ /**
73
+ * Tarball data reader
74
+ *
75
+ * @var Mage_Archive_Helper_File
76
+ */
77
+ protected $_reader;
78
+
79
+ /**
80
+ * Path to file where tarball should be placed
81
+ *
82
+ * @var string
83
+ */
84
+ protected $_destinationFilePath;
85
+
86
+ /**
87
+ * Initialize tarball writer
88
+ *
89
+ * @return Mage_Archive_Tar
90
+ */
91
+ protected function _initWriter()
92
+ {
93
+ $this->_writer = new Mage_Archive_Helper_File($this->_destinationFilePath);
94
+ $this->_writer->open('w');
95
+
96
+ return $this;
97
+ }
98
+
99
+ /**
100
+ * Returns string that is used for tar's header parsing
101
+ *
102
+ * @return string
103
+ */
104
+ protected static final function _getFormatParseHeader()
105
+ {
106
+ return 'a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2version/'
107
+ . 'a32uname/a32gname/a8devmajor/a8devminor/a155prefix/a12closer';
108
+ }
109
+
110
+ /**
111
+ * Destroy tarball writer
112
+ *
113
+ * @return Mage_Archive_Tar
114
+ */
115
+ protected function _destroyWriter()
116
+ {
117
+ if ($this->_writer instanceof Mage_Archive_Helper_File) {
118
+ $this->_writer->close();
119
+ $this->_writer = null;
120
+ }
121
+
122
+ return $this;
123
+ }
124
+
125
+ /**
126
+ * Get tarball writer
127
+ *
128
+ * @return Mage_Archive_Helper_File
129
+ */
130
+ protected function _getWriter()
131
+ {
132
+ if (!$this->_writer) {
133
+ $this->_initWriter();
134
+ }
135
+
136
+ return $this->_writer;
137
+ }
138
+
139
+ /**
140
+ * Initialize tarball reader
141
+ *
142
+ * @return Mage_Archive_Tar
143
+ */
144
+ protected function _initReader()
145
+ {
146
+ $this->_reader = new Mage_Archive_Helper_File($this->_getCurrentFile());
147
+ $this->_reader->open('r');
148
+
149
+ return $this;
150
+ }
151
+
152
+ /**
153
+ * Destroy tarball reader
154
+ *
155
+ * @return Mage_Archive_Tar
156
+ */
157
+ protected function _destroyReader()
158
+ {
159
+ if ($this->_reader instanceof Mage_Archive_Helper_File) {
160
+ $this->_reader->close();
161
+ $this->_reader = null;
162
+ }
163
+
164
+ return $this;
165
+ }
166
+
167
+ /**
168
+ * Get tarball reader
169
+ *
170
+ * @return Mage_Archive_Helper_File
171
+ */
172
+ protected function _getReader()
173
+ {
174
+ if (!$this->_reader) {
175
+ $this->_initReader();
176
+ }
177
+
178
+ return $this->_reader;
179
+ }
180
+
181
  /**
182
  * Set option that define ability skip first catalog level.
183
  *
198
  */
199
  protected function _setCurrentFile($file)
200
  {
201
+ $this->_currentFile = $file .((!is_link($file) && is_dir($file) && substr($file, -1) != DS) ? DS : '');
202
+ return $this;
203
+ }
204
+
205
+ /**
206
+ * Set path to file where tarball should be placed
207
+ *
208
+ * @param string $destinationFilePath
209
+ * @return Mage_Archive_Tar
210
+ */
211
+ protected function _setDestinationFilePath($destinationFilePath)
212
+ {
213
+ $this->_destinationFilePath = $destinationFilePath;
214
  return $this;
215
  }
216
 
254
  * Walk through directory and add to tar file or directory.
255
  * Result is packed string on TAR format.
256
  *
257
+ * @deprecated after 1.7.0.0
258
  * @param boolean $skipRoot
259
  * @return string
260
  */
285
  return $tarData;
286
  }
287
 
288
+ /**
289
+ * Recursively walk through file tree and create tarball
290
+ *
291
+ * @param boolean $skipRoot
292
+ * @param boolean $finalize
293
+ * @throws Mage_Exception
294
+ */
295
+ protected function _createTar($skipRoot = false, $finalize = false)
296
+ {
297
+ if (!$skipRoot) {
298
+ $this->_packAndWriteCurrentFile();
299
+ }
300
+
301
+ $file = $this->_getCurrentFile();
302
+
303
+ if (is_dir($file)) {
304
+ $dirFiles = scandir($file);
305
+
306
+ if (false === $dirFiles) {
307
+ throw new Mage_Exception('Can\'t scan dir: ' . $file);
308
+ }
309
+
310
+ array_shift($dirFiles); /* remove './'*/
311
+ array_shift($dirFiles); /* remove '../'*/
312
+
313
+ foreach ($dirFiles as $item) {
314
+ $this->_setCurrentFile($file . $item)->_createTar();
315
+ }
316
+ }
317
+
318
+ if ($finalize) {
319
+ $this->_getWriter()->write(str_repeat("\0", self::TAR_BLOCK_SIZE * 12));
320
+ }
321
+ }
322
+
323
+ /**
324
+ * Write current file to tarball
325
+ */
326
+ protected function _packAndWriteCurrentFile()
327
+ {
328
+ $archiveWriter = $this->_getWriter();
329
+ $archiveWriter->write($this->_composeHeader());
330
+
331
+ $currentFile = $this->_getCurrentFile();
332
+
333
+ $fileSize = 0;
334
+
335
+ if (is_file($currentFile) && !is_link($currentFile)) {
336
+ $fileReader = new Mage_Archive_Helper_File($currentFile);
337
+ $fileReader->open('r');
338
+
339
+ while (!$fileReader->eof()) {
340
+ $archiveWriter->write($fileReader->read());
341
+ }
342
+
343
+ $fileReader->close();
344
+
345
+ $fileSize = filesize($currentFile);
346
+ }
347
+
348
+ $appendZerosCount = (self::TAR_BLOCK_SIZE - $fileSize % self::TAR_BLOCK_SIZE) % self::TAR_BLOCK_SIZE;
349
+ $archiveWriter->write(str_repeat("\0", $appendZerosCount));
350
+ }
351
+
352
  /**
353
  * Compose header for current file in TAR format.
354
  * If length of file's name greater 100 characters,
355
+ * method breaks header into two pieces. First contains
356
  * header and data with long name. Second contain only header.
357
  *
358
  * @param boolean $long
373
  }
374
  $header = array();
375
  $header['100-name'] = $long?'././@LongLink':substr($nameFile, 0, 100);
376
+ $header['8-mode'] = $long ? ' '
377
+ : str_pad(substr(sprintf("%07o", $infoFile['mode']),-4), 6, '0', STR_PAD_LEFT);
378
  $header['8-uid'] = $long || $infoFile['uid']==0?"\0\0\0\0\0\0\0":sprintf("%07o", $infoFile['uid']);
379
  $header['8-gid'] = $long || $infoFile['gid']==0?"\0\0\0\0\0\0\0":sprintf("%07o", $infoFile['gid']);
380
+ $header['12-size'] = $long ? sprintf("%011o", strlen($nameFile)) : sprintf("%011o", is_dir($file)
381
+ ? 0 : filesize($file));
382
  $header['12-mtime'] = $long?'00000000000':sprintf("%011o", $infoFile['mtime']);
383
  $header['8-check'] = sprintf('% 8s', '');
384
+ $header['1-type'] = $long ? 'L' : (is_link($file) ? 2 : (is_dir($file) ? 5 : 0));
385
+ $header['100-symlink'] = is_link($file) ? readlink($file) : '';
386
  $header['6-magic'] = 'ustar ';
387
  $header['2-version'] = ' ';
388
  $a=function_exists('posix_getpwuid')?posix_getpwuid (fileowner($file)):array('name'=>'');
416
  *
417
  * @param string $destination path to file is unpacked
418
  * @return array list of files
419
+ * @throws Mage_Exception
420
  */
421
  protected function _unpackCurrentTar($destination)
422
  {
423
+ $archiveReader = $this->_getReader();
 
 
 
 
424
  $list = array();
425
+
426
+ while (!$archiveReader->eof()) {
427
+ $header = $this->_extractFileHeader();
428
+
429
+ if (!$header) {
430
+ continue;
431
+ }
432
+
433
+ $currentFile = $destination . $header['name'];
434
+ $dirname = dirname($currentFile);
435
+
436
+ if (in_array($header['type'], array("0",chr(0), ''))) {
437
+
438
+ if(!file_exists($dirname)) {
439
+ $mkdirResult = @mkdir($dirname, 0777, true);
440
+
441
+ if (false === $mkdirResult) {
442
+ throw new Mage_Exception('Failed to create directory ' . $dirname);
443
  }
444
+ }
445
+
446
+ $this->_extractAndWriteFile($header, $currentFile);
447
+ $list[] = $currentFile;
448
+
449
+ } elseif ($header['type'] == '5') {
450
+
451
+ if(!file_exists($dirname)) {
452
+ $mkdirResult = @mkdir($currentFile, $header['mode'], true);
453
+
454
+ if (false === $mkdirResult) {
455
+ throw new Mage_Exception('Failed to create directory ' . $currentFile);
456
+ }
457
+ }
458
+ $list[] = $currentFile . DS;
459
+ } elseif ($header['type'] == '2') {
460
+
461
+ $symlinkResult = @symlink($header['symlink'], $currentFile);
462
+
463
+ if (false === $symlinkResult) {
464
+ throw new Mage_Exception('Failed to create symlink ' . $currentFile . ' to ' . $header['symlink']);
465
  }
466
  }
467
  }
468
+
469
  return $list;
470
  }
471
 
472
  /**
473
  * Get header from TAR string and unpacked it by format.
474
  *
475
+ * @deprecated after 1.7.0.0
476
  * @param resource $pointer
477
  * @return string
478
  */
484
  return false;
485
  }
486
 
487
+ $fmt = self::_getFormatParseHeader();
488
  $header = unpack ($fmt, $firstLine);
489
 
 
490
  $header['mode']=$header['mode']+0;
491
  $header['uid']=octdec($header['uid']);
492
  $header['gid']=octdec($header['gid']);
505
  }
506
 
507
  $isUstar = 'ustar' == strtolower(substr($header['magic'], 0, 5));
508
+
509
  $checksumOk = $header['checksum'] == $checksum;
510
  if (isset($header['name']) && $checksumOk) {
511
  if ($header['name'] == '././@LongLink' && $header['type'] == 'L') {
525
  return false;
526
  }
527
 
528
+ /**
529
+ * Read and decode file header information from tarball
530
+ *
531
+ * @return array|boolean
532
+ */
533
+ protected function _extractFileHeader()
534
+ {
535
+ $archiveReader = $this->_getReader();
536
+
537
+ $headerBlock = $archiveReader->read(self::TAR_BLOCK_SIZE);
538
+
539
+ if (strlen($headerBlock) < self::TAR_BLOCK_SIZE) {
540
+ return false;
541
+ }
542
+
543
+ $header = unpack(self::_getFormatParseHeader(), $headerBlock);
544
+
545
+ $header['mode'] = octdec($header['mode']);
546
+ $header['uid'] = octdec($header['uid']);
547
+ $header['gid'] = octdec($header['gid']);
548
+ $header['size'] = octdec($header['size']);
549
+ $header['mtime'] = octdec($header['mtime']);
550
+ $header['checksum'] = octdec($header['checksum']);
551
+
552
+ if ($header['type'] == "5") {
553
+ $header['size'] = 0;
554
+ }
555
+
556
+ $checksum = 0;
557
+ $headerBlock = substr_replace($headerBlock, ' ', 148, 8);
558
+
559
+ for ($i = 0; $i < 512; $i++) {
560
+ $checksum += ord(substr($headerBlock, $i, 1));
561
+ }
562
+
563
+ $isUstar = 'ustar' == strtolower(substr($header['magic'], 0, 5));
564
+
565
+ $checksumOk = $header['checksum'] == $checksum;
566
+ if (isset($header['name']) && $checksumOk) {
567
+
568
+ if (!($header['name'] == '././@LongLink' && $header['type'] == 'L')) {
569
+ return $header;
570
+ }
571
+
572
+ $realNameBlockSize = floor(($header['size'] + self::TAR_BLOCK_SIZE - 1) / self::TAR_BLOCK_SIZE)
573
+ * self::TAR_BLOCK_SIZE;
574
+ $realNameBlock = $archiveReader->read($realNameBlockSize);
575
+ $realName = substr($realNameBlock, 0, $header['size']);
576
+
577
+ $headerMain = $this->_extractFileHeader();
578
+ $headerMain['name'] = $realName;
579
+ return $headerMain;
580
+ }
581
+
582
+ return false;
583
+ }
584
+
585
+ /**
586
+ * Extract next file from tarball by its $header information and save it to $destination
587
+ *
588
+ * @param array $fileHeader
589
+ * @param string $destination
590
+ */
591
+ protected function _extractAndWriteFile($fileHeader, $destination)
592
+ {
593
+ $fileWriter = new Mage_Archive_Helper_File($destination);
594
+ $fileWriter->open('w', $fileHeader['mode']);
595
+
596
+ $archiveReader = $this->_getReader();
597
+
598
+ $filesize = $fileHeader['size'];
599
+ $bytesExtracted = 0;
600
+
601
+ while ($filesize > $bytesExtracted && !$archiveReader->eof()) {
602
+ $block = $archiveReader->read(self::TAR_BLOCK_SIZE);
603
+ $nonExtractedBytesCount = $filesize - $bytesExtracted;
604
+
605
+ $data = substr($block, 0, $nonExtractedBytesCount);
606
+ $fileWriter->write($data);
607
+
608
+ $bytesExtracted += strlen($block);
609
+ }
610
+ }
611
+
612
  /**
613
  * Pack file to TAR (Tape Archiver).
614
  *
617
  * @param boolean $skipRoot
618
  * @return string
619
  */
620
+ public function pack($source, $destination, $skipRoot = false)
621
  {
622
  $this->_setSkipRoot($skipRoot);
623
  $source = realpath($source);
624
  $tarData = $this->_setCurrentPath($source)
625
+ ->_setDestinationFilePath($destination)
626
+ ->_setCurrentFile($source);
627
+
628
+ $this->_initWriter();
629
+ $this->_createTar($skipRoot, true);
630
+ $this->_destroyWriter();
631
+
632
  return $destination;
633
  }
634
 
641
  */
642
  public function unpack($source, $destination)
643
  {
644
+ $this->_setCurrentFile($source)
645
+ ->_setCurrentPath($source);
646
+
647
+ $this->_initReader();
648
+ $this->_unpackCurrentTar($destination);
649
+ $this->_destroyReader();
650
+
651
  return $destination;
652
  }
653
 
661
  */
662
  public function extract($file, $source, $destination)
663
  {
664
+ $this->_setCurrentFile($source);
665
+ $this->_initReader();
666
+
667
+ $archiveReader = $this->_getReader();
 
668
  $extractedFile = '';
669
+
670
+ while (!$archiveReader->eof()) {
671
+ $header = $this->_extractFileHeader();
672
  if ($header['name'] == $file) {
673
  $extractedFile = $destination . basename($header['name']);
674
+ $this->_extractAndWriteFile($header, $extractedFile);
675
  break;
676
  }
677
+
678
+ if ($header['type'] != 5){
679
+ $skipBytes = floor(($header['size'] + self::TAR_BLOCK_SIZE - 1) / self::TAR_BLOCK_SIZE)
680
+ * self::TAR_BLOCK_SIZE;
681
+ $archiveReader->read($skipBytes);
682
+ }
683
  }
684
+
685
+ $this->_destroyReader();
686
  return $extractedFile;
687
  }
688
  }
downloader/lib/Mage/Autoload/Simple.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_Autoload
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_Autoload
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/Backup.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Backup
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
+ * Class to work with backups
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Backup
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Backup
35
+ {
36
+ /**
37
+ * List of supported a backup types
38
+ *
39
+ * @var array
40
+ */
41
+ static protected $_allowedBackupTypes = array('db', 'snapshot', 'filesystem', 'media', 'nomedia');
42
+
43
+ /**
44
+ * get Backup Instance By File Name
45
+ *
46
+ * @param string $type
47
+ * @return Mage_Backup_Interface
48
+ */
49
+ static public function getBackupInstance($type)
50
+ {
51
+ $class = 'Mage_Backup_' . ucfirst($type);
52
+
53
+ if (!in_array($type, self::$_allowedBackupTypes) || !class_exists($class, true)){
54
+ throw new Mage_Exception('Current implementation not supported this type (' . $type . ') of backup.');
55
+ }
56
+
57
+ return new $class();
58
+ }
59
+ }
downloader/lib/Mage/Backup/Abstract.php ADDED
@@ -0,0 +1,318 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Backup
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
+ * Class to work with archives
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Backup
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ abstract class Mage_Backup_Abstract implements Mage_Backup_Interface
35
+ {
36
+ /**
37
+ * Backup name
38
+ *
39
+ * @var string
40
+ */
41
+ protected $_name;
42
+
43
+ /**
44
+ * Backup creation date
45
+ *
46
+ * @var int
47
+ */
48
+ protected $_time;
49
+
50
+ /**
51
+ * Backup file extension
52
+ *
53
+ * @var string
54
+ */
55
+ protected $_backupExtension;
56
+
57
+ /**
58
+ * Resource model
59
+ *
60
+ * @var object
61
+ */
62
+ protected $_resourceModel;
63
+
64
+ /**
65
+ * Magento's root directory
66
+ *
67
+ * @var string
68
+ */
69
+ protected $_rootDir;
70
+
71
+ /**
72
+ * Path to directory where backups stored
73
+ *
74
+ * @var string
75
+ */
76
+ protected $_backupsDir;
77
+
78
+ /**
79
+ * Is last operation completed successfully
80
+ *
81
+ * @var bool
82
+ */
83
+ protected $_lastOperationSucceed = false;
84
+
85
+ /**
86
+ * Last failed operation error message
87
+ *
88
+ * @var string
89
+ */
90
+ protected $_lastErrorMessage;
91
+
92
+
93
+ /**
94
+ * Set Backup Extension
95
+ *
96
+ * @param string $backupExtension
97
+ * @return Mage_Backup_Interface
98
+ */
99
+ public function setBackupExtension($backupExtension)
100
+ {
101
+ $this->_backupExtension = $backupExtension;
102
+ return $this;
103
+ }
104
+
105
+ /**
106
+ * Get Backup Extension
107
+ *
108
+ * @return string
109
+ */
110
+ public function getBackupExtension()
111
+ {
112
+ return $this->_backupExtension;
113
+ }
114
+
115
+ /**
116
+ * Set Resource Model
117
+ *
118
+ * @param object $resourceModel
119
+ * @return Mage_Backup_Interface
120
+ */
121
+ public function setResourceModel($resourceModel)
122
+ {
123
+ $this->_resourceModel = $resourceModel;
124
+ return $this;
125
+ }
126
+
127
+ /**
128
+ * Get Resource Model
129
+ *
130
+ * @return object
131
+ */
132
+ public function getResourceModel()
133
+ {
134
+ return $this->_resourceModel;
135
+ }
136
+
137
+ /**
138
+ * Set Time
139
+ *
140
+ * @param int $time
141
+ * @return Mage_Backup_Interface
142
+ */
143
+ public function setTime($time)
144
+ {
145
+ $this->_time = $time;
146
+ return $this;
147
+ }
148
+
149
+ /**
150
+ * Get Time
151
+ *
152
+ * @return int
153
+ */
154
+ public function getTime()
155
+ {
156
+ return $this->_time;
157
+ }
158
+
159
+ /**
160
+ * Set root directory of Magento installation
161
+ *
162
+ * @param string $rootDir
163
+ * @throws Mage_Exception
164
+ * @return Mage_Backup_Interface
165
+ */
166
+ public function setRootDir($rootDir)
167
+ {
168
+ if (!is_dir($rootDir)) {
169
+ throw new Mage_Exception('Bad root directory');
170
+ }
171
+
172
+ $this->_rootDir = $rootDir;
173
+ return $this;
174
+ }
175
+
176
+ /**
177
+ * Get Magento's root directory
178
+ * @return string
179
+ */
180
+ public function getRootDir()
181
+ {
182
+ return $this->_rootDir;
183
+ }
184
+
185
+ /**
186
+ * Set path to directory where backups stored
187
+ *
188
+ * @param string $backupsDir
189
+ * @return Mage_Backup_Interface
190
+ */
191
+ public function setBackupsDir($backupsDir)
192
+ {
193
+ $this->_backupsDir = $backupsDir;
194
+ return $this;
195
+ }
196
+
197
+ /**
198
+ * Get path to directory where backups stored
199
+ *
200
+ * @return string
201
+ */
202
+ public function getBackupsDir()
203
+ {
204
+ return $this->_backupsDir;
205
+ }
206
+
207
+ /**
208
+ * Get path to backup
209
+ *
210
+ * @return string
211
+ */
212
+ public function getBackupPath()
213
+ {
214
+ return $this->getBackupsDir() . DS . $this->getBackupFilename();
215
+ }
216
+
217
+ /**
218
+ * Get backup file name
219
+ *
220
+ * @return string
221
+ */
222
+ public function getBackupFilename()
223
+ {
224
+ $filename = $this->getTime() . '_' . $this->getType();
225
+
226
+ $name = $this->getName();
227
+
228
+ if (!empty($name)) {
229
+ $filename .= '_' . $name;
230
+ }
231
+
232
+ $filename .= '.' . $this->getBackupExtension();
233
+
234
+ return $filename;
235
+ }
236
+
237
+ /**
238
+ * Check whether last operation completed successfully
239
+ *
240
+ * @return bool
241
+ */
242
+ public function getIsSuccess()
243
+ {
244
+ return $this->_lastOperationSucceed;
245
+ }
246
+
247
+ /**
248
+ * Get last error message
249
+ *
250
+ * @return string
251
+ */
252
+ public function getErrorMessage()
253
+ {
254
+ return $this->_lastErrorMessage;
255
+ }
256
+
257
+ /**
258
+ * Set error message
259
+ *
260
+ * @param string $errorMessage
261
+ * @return string
262
+ */
263
+ public function setErrorMessage($errorMessage)
264
+ {
265
+ $this->_lastErrorMessage = $errorMessage;
266
+ }
267
+
268
+ /**
269
+ * Set backup name
270
+ *
271
+ * @param string $name
272
+ * @param bool $applyFilter
273
+ * @return Mage_Backup_Interface
274
+ */
275
+ public function setName($name, $applyFilter = true)
276
+ {
277
+ if ($applyFilter) {
278
+ $name = $this->_filterName($name);
279
+ }
280
+ $this->_name = $name;
281
+ return $this;
282
+ }
283
+
284
+ /**
285
+ * Get backup name
286
+ *
287
+ * @return string
288
+ */
289
+ public function getName()
290
+ {
291
+ return $this->_name;
292
+ }
293
+
294
+ /**
295
+ * Get backup display name
296
+ *
297
+ * @return string
298
+ */
299
+ public function getDisplayName()
300
+ {
301
+ return str_replace('_', ' ', $this->_name);
302
+ }
303
+
304
+ /**
305
+ * Removes disallowed characters and replaces spaces with underscores
306
+ *
307
+ * @param string $name
308
+ * @return string
309
+ */
310
+ protected function _filterName($name)
311
+ {
312
+ $name = trim(preg_replace('/[^\da-zA-Z ]/', '', $name));
313
+ $name = preg_replace('/\s{2,}/', ' ', $name);
314
+ $name = str_replace(' ', '_', $name);
315
+
316
+ return $name;
317
+ }
318
+ }
downloader/lib/Mage/Backup/Archive/Tar.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Backup
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
+ * Extended version of Mage_Archive_Tar that supports filtering
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Backup
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Backup_Archive_Tar extends Mage_Archive_Tar
35
+ {
36
+ /**
37
+ * Filenames or filename parts that are used for filtering files
38
+ *
39
+ * @var array()
40
+ */
41
+ protected $_skipFiles = array();
42
+
43
+ /**
44
+ * Overridden Mage_Archive_Tar::_createTar method that does the same actions as it's parent but filters
45
+ * files using Mage_Backup_Filesystem_Iterator_Filter
46
+ *
47
+ * @see Mage_Archive_Tar::_createTar()
48
+ * @param bool $skipRoot
49
+ * @param bool $finalize
50
+ */
51
+ protected function _createTar($skipRoot = false, $finalize = false)
52
+ {
53
+ $path = $this->_getCurrentFile();
54
+
55
+ $filesystemIterator = new RecursiveIteratorIterator(
56
+ new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST
57
+ );
58
+
59
+ $iterator = new Mage_Backup_Filesystem_Iterator_Filter($filesystemIterator, $this->_skipFiles);
60
+
61
+ foreach ($iterator as $item) {
62
+ $this->_setCurrentFile($item->getPathname());
63
+ $this->_packAndWriteCurrentFile();
64
+ }
65
+
66
+ if ($finalize) {
67
+ $this->_getWriter()->write(str_repeat("\0", self::TAR_BLOCK_SIZE * 12));
68
+ }
69
+ }
70
+
71
+ /**
72
+ * Set files that shouldn't be added to tarball
73
+ *
74
+ * @param array $skipFiles
75
+ * @return Mage_Backup_Archive_Tar
76
+ */
77
+ public function setSkipFiles(array $skipFiles)
78
+ {
79
+ $this->_skipFiles = $skipFiles;
80
+ return $this;
81
+ }
82
+ }
downloader/lib/Mage/Backup/Db.php ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Backup
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
+ * Class to work with database backups
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Backup
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Backup_Db extends Mage_Backup_Abstract
35
+ {
36
+ /**
37
+ * Implements Rollback functionality for Db
38
+ *
39
+ * @return bool
40
+ */
41
+ public function rollback()
42
+ {
43
+ set_time_limit(0);
44
+ ignore_user_abort(true);
45
+
46
+ $this->_lastOperationSucceed = false;
47
+
48
+ $archiveManager = new Mage_Archive();
49
+ $source = $archiveManager->unpack($this->getBackupPath(), $this->getBackupsDir());
50
+
51
+ $file = new Mage_Backup_Filesystem_Iterator_File($source);
52
+ foreach ($file as $statement) {
53
+ $this->getResourceModel()->runCommand($statement);
54
+ }
55
+ @unlink($source);
56
+
57
+ $this->_lastOperationSucceed = true;
58
+
59
+ return true;
60
+ }
61
+
62
+ /**
63
+ * Checks whether the line is last in sql command
64
+ *
65
+ * @param $line
66
+ * @return bool
67
+ */
68
+ protected function _isLineLastInCommand($line)
69
+ {
70
+ $cleanLine = trim($line);
71
+ $lineLength = strlen($cleanLine);
72
+
73
+ $returnResult = false;
74
+ if ($lineLength > 0){
75
+ $lastSymbolIndex = $lineLength-1;
76
+ if ($cleanLine[$lastSymbolIndex] == ';'){
77
+ $returnResult = true;
78
+ }
79
+ }
80
+
81
+ return $returnResult;
82
+ }
83
+
84
+ /**
85
+ * Implements Create Backup functionality for Db
86
+ *
87
+ * @return bool
88
+ */
89
+ public function create()
90
+ {
91
+ set_time_limit(0);
92
+ ignore_user_abort(true);
93
+
94
+ $this->_lastOperationSucceed = false;
95
+
96
+ $backup = Mage::getModel('backup/backup')
97
+ ->setTime($this->getTime())
98
+ ->setType($this->getType())
99
+ ->setPath($this->getBackupsDir())
100
+ ->setName($this->getName());
101
+
102
+ $backupDb = Mage::getModel('backup/db');
103
+ $backupDb->createBackup($backup);
104
+
105
+ $this->_lastOperationSucceed = true;
106
+
107
+ return true;
108
+ }
109
+
110
+ /**
111
+ * Get Backup Type
112
+ *
113
+ * @return string
114
+ */
115
+ public function getType()
116
+ {
117
+ return 'db';
118
+ }
119
+ }
downloader/lib/Mage/Backup/Exception.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Backup
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
+ * Exception
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Backup
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Backup_Exception extends Mage_Exception
35
+ {
36
+ }
downloader/lib/Mage/Backup/Exception/CantLoadSnapshot.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Backup
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
+ * Exception
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Backup
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Backup_Exception_CantLoadSnapshot extends Mage_Backup_Exception
35
+ {
36
+ }
downloader/lib/Mage/Backup/Exception/FtpConnectionFailed.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Backup
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
+ * Exception
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Backup
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Backup_Exception_FtpConnectionFailed extends Mage_Backup_Exception
35
+ {
36
+ }
downloader/lib/Mage/Backup/Exception/FtpValidationFailed.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Backup
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
+ * Exception
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Backup
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Backup_Exception_FtpValidationFailed extends Mage_Backup_Exception
35
+ {
36
+ }
downloader/lib/Mage/Backup/Exception/NotEnoughFreeSpace.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Backup
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
+ * Exception
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Backup
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Backup_Exception_NotEnoughFreeSpace extends Mage_Backup_Exception
35
+ {
36
+ }
downloader/lib/Mage/Backup/Exception/NotEnoughPermissions.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Backup
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
+ * Exception
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Backup
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Backup_Exception_NotEnoughPermissions extends Mage_Backup_Exception
35
+ {
36
+ }
downloader/lib/Mage/Backup/Filesystem.php ADDED
@@ -0,0 +1,284 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Backup
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
+ * Class to work with filesystem backups
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Backup
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Backup_Filesystem extends Mage_Backup_Abstract
35
+ {
36
+ /**
37
+ * Paths that ignored when creating or rolling back snapshot
38
+ *
39
+ * @var array
40
+ */
41
+ protected $_ignorePaths = array();
42
+
43
+ /**
44
+ * Whether use ftp account for rollback procedure
45
+ *
46
+ * @var bool
47
+ */
48
+ protected $_useFtp = false;
49
+
50
+ /**
51
+ * Ftp host
52
+ *
53
+ * @var string
54
+ */
55
+ protected $_ftpHost;
56
+
57
+ /**
58
+ * Ftp username
59
+ *
60
+ * @var string
61
+ */
62
+ protected $_ftpUser;
63
+
64
+ /**
65
+ * Password to ftp account
66
+ *
67
+ * @var string
68
+ */
69
+ protected $_ftpPass;
70
+
71
+ /**
72
+ * Ftp path to Magento installation
73
+ *
74
+ * @var string
75
+ */
76
+ protected $_ftpPath;
77
+
78
+ /**
79
+ * Implementation Rollback functionality for Filesystem
80
+ *
81
+ * @throws Mage_Exception
82
+ * @return bool
83
+ */
84
+ public function rollback()
85
+ {
86
+ $this->_lastOperationSucceed = false;
87
+
88
+ set_time_limit(0);
89
+ ignore_user_abort(true);
90
+
91
+ $rollbackWorker = $this->_useFtp ? new Mage_Backup_Filesystem_Rollback_Ftp($this)
92
+ : new Mage_Backup_Filesystem_Rollback_Fs($this);
93
+ $rollbackWorker->run();
94
+
95
+ $this->_lastOperationSucceed = true;
96
+ }
97
+
98
+ /**
99
+ * Implementation Create Backup functionality for Filesystem
100
+ *
101
+ * @throws Mage_Exception
102
+ * @return boolean
103
+ */
104
+ public function create()
105
+ {
106
+ set_time_limit(0);
107
+ ignore_user_abort(true);
108
+
109
+ $this->_lastOperationSucceed = false;
110
+
111
+ $this->_checkBackupsDir();
112
+
113
+ $fsHelper = new Mage_Backup_Filesystem_Helper();
114
+
115
+ $filesInfo = $fsHelper->getInfo(
116
+ $this->getRootDir(),
117
+ Mage_Backup_Filesystem_Helper::INFO_READABLE | Mage_Backup_Filesystem_Helper::INFO_SIZE,
118
+ $this->getIgnorePaths()
119
+ );
120
+
121
+ if (!$filesInfo['readable']) {
122
+ throw new Mage_Backup_Exception_NotEnoughPermissions('Not enough permissions to read files for backup');
123
+ }
124
+
125
+ $freeSpace = disk_free_space($this->getBackupsDir());
126
+
127
+ if (2 * $filesInfo['size'] > $freeSpace) {
128
+ throw new Mage_Backup_Exception_NotEnoughFreeSpace('Not enough free space to create backup');
129
+ }
130
+
131
+ $tarTmpPath = $this->_getTarTmpPath();
132
+
133
+ $tarPacker = new Mage_Backup_Archive_Tar();
134
+ $tarPacker->setSkipFiles($this->getIgnorePaths())
135
+ ->pack($this->getRootDir(), $tarTmpPath, true);
136
+
137
+ if (!is_file($tarTmpPath) || filesize($tarTmpPath) == 0) {
138
+ throw new Mage_Exception('Failed to create backup');
139
+ }
140
+
141
+ $backupPath = $this->getBackupPath();
142
+
143
+ $gzPacker = new Mage_Archive_Gz();
144
+ $gzPacker->pack($tarTmpPath, $backupPath);
145
+
146
+ if (!is_file($backupPath) || filesize($backupPath) == 0) {
147
+ throw new Mage_Exception('Failed to create backup');
148
+ }
149
+
150
+ @unlink($tarTmpPath);
151
+
152
+ $this->_lastOperationSucceed = true;
153
+ }
154
+
155
+ /**
156
+ * Force class to use ftp for rollback procedure
157
+ *
158
+ * @param string $host
159
+ * @param string $username
160
+ * @param string $password
161
+ * @param string $path
162
+ * @return Mage_Backup_Filesystem
163
+ */
164
+ public function setUseFtp($host, $username, $password, $path)
165
+ {
166
+ $this->_useFtp = true;
167
+ $this->_ftpHost = $host;
168
+ $this->_ftpUser = $username;
169
+ $this->_ftpPass = $password;
170
+ $this->_ftpPath = $path;
171
+ return $this;
172
+ }
173
+
174
+ /**
175
+ * Get backup type
176
+ *
177
+ * @see Mage_Backup_Interface::getType()
178
+ * @return string
179
+ */
180
+ public function getType()
181
+ {
182
+ return 'filesystem';
183
+ }
184
+
185
+ /**
186
+ * Add path that should be ignoring when creating or rolling back backup
187
+ *
188
+ * @param string|array $paths
189
+ * @return Mage_Backup_Filesystem
190
+ */
191
+ public function addIgnorePaths($paths)
192
+ {
193
+ if (is_string($paths)) {
194
+ if (!in_array($paths, $this->_ignorePaths)) {
195
+ $this->_ignorePaths[] = $paths;
196
+ }
197
+ }
198
+ else if (is_array($paths)) {
199
+ foreach ($paths as $path) {
200
+ $this->addIgnorePaths($path);
201
+ }
202
+ }
203
+
204
+ return $this;
205
+ }
206
+
207
+ /**
208
+ * Get paths that should be ignored while creating or rolling back backup procedure
209
+ *
210
+ * @return array
211
+ */
212
+ public function getIgnorePaths()
213
+ {
214
+ return $this->_ignorePaths;
215
+ }
216
+
217
+ /**
218
+ * Set directory where backups saved and add it to ignore paths
219
+ *
220
+ * @see Mage_Backup_Abstract::setBackupsDir()
221
+ * @param string $backupsDir
222
+ * @return Mage_Backup_Filesystem
223
+ */
224
+ public function setBackupsDir($backupsDir)
225
+ {
226
+ parent::setBackupsDir($backupsDir);
227
+ $this->addIgnorePaths($backupsDir);
228
+ return $this;
229
+ }
230
+
231
+ /**
232
+ * getter for $_ftpPath variable
233
+ *
234
+ * @return string
235
+ */
236
+ public function getFtpPath()
237
+ {
238
+ return $this->_ftpPath;
239
+ }
240
+
241
+ /**
242
+ * Get ftp connection string
243
+ *
244
+ * @return string
245
+ */
246
+ public function getFtpConnectString()
247
+ {
248
+ return 'ftp://' . $this->_ftpUser . ':' . $this->_ftpPass . '@' . $this->_ftpHost . $this->_ftpPath;
249
+ }
250
+
251
+ /**
252
+ * Check backups directory existance and whether it's writeable
253
+ *
254
+ * @throws Mage_Exception
255
+ */
256
+ protected function _checkBackupsDir()
257
+ {
258
+ $backupsDir = $this->getBackupsDir();
259
+
260
+ if (!is_dir($backupsDir)) {
261
+ $backupsDirParentDirectory = basename($backupsDir);
262
+
263
+ if (!is_writeable($backupsDirParentDirectory)) {
264
+ throw new Mage_Backup_Exception_NotEnoughPermissions('Cant create backups directory');
265
+ }
266
+
267
+ mkdir($backupsDir);
268
+ chmod($backupsDir, 0777);
269
+ }
270
+
271
+ if (!is_writable($backupsDir)) {
272
+ throw new Mage_Backup_Exception_NotEnoughPermissions('Backups directory is not writeable');
273
+ }
274
+ }
275
+
276
+ /**
277
+ * Generate tmp name for tarball
278
+ */
279
+ protected function _getTarTmpPath()
280
+ {
281
+ $tmpName = '~tmp-'. microtime(true) . '.tar';
282
+ return $this->getBackupsDir() . DS . $tmpName;
283
+ }
284
+ }
downloader/lib/Mage/Backup/Filesystem/Helper.php ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Backup
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
+ * Filesystem helper for Mage_Backup library
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Backup
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Backup_Filesystem_Helper
35
+ {
36
+ /**
37
+ * Constant can be used in getInfo() function as second parameter.
38
+ * Check whether directory and all files/sub directories are writable
39
+ *
40
+ * @const int
41
+ */
42
+ const INFO_WRITABLE = 1;
43
+
44
+ /**
45
+ * Constant can be used in getInfo() function as second parameter.
46
+ * Check whether directory and all files/sub directories are readable
47
+ *
48
+ * @const int
49
+ */
50
+ const INFO_READABLE = 2;
51
+
52
+ /**
53
+ * Constant can be used in getInfo() function as second parameter.
54
+ * Get directory size
55
+ *
56
+ * @const int
57
+ */
58
+ const INFO_SIZE = 4;
59
+
60
+ /**
61
+ * Constant can be used in getInfo() function as second parameter.
62
+ * Combination of INFO_WRITABLE, INFO_READABLE, INFO_SIZE
63
+ *
64
+ * @const int
65
+ */
66
+ const INFO_ALL = 7;
67
+
68
+ /**
69
+ * Recursively delete $path
70
+ *
71
+ * @param string $path
72
+ * @param array $skipPaths
73
+ * @param bool $removeRoot
74
+ * @throws Mage_Exception
75
+ */
76
+ public function rm($path, $skipPaths = array(), $removeRoot = false)
77
+ {
78
+ $filesystemIterator = new RecursiveIteratorIterator(
79
+ new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::CHILD_FIRST
80
+ );
81
+
82
+ $iterator = new Mage_Backup_Filesystem_Iterator_Filter($filesystemIterator, $skipPaths);
83
+
84
+ foreach ($iterator as $item) {
85
+ $item->isDir() ? @rmdir($item->__toString()) : @unlink($item->__toString());
86
+ }
87
+
88
+ if ($removeRoot && is_dir($path)) {
89
+ @rmdir($path);
90
+ }
91
+ }
92
+
93
+ /**
94
+ * Get information (readable, writable, size) about $path
95
+ *
96
+ * @param string $path
97
+ * @param int $infoOptions
98
+ * @param array $skipFiles
99
+ */
100
+ public function getInfo($path, $infoOptions = self::INFO_ALL, $skipFiles = array())
101
+ {
102
+ $info = array();
103
+ if ($infoOptions & self::INFO_READABLE) {
104
+ $info['readable'] = true;
105
+ }
106
+
107
+ if ($infoOptions & self::INFO_WRITABLE) {
108
+ $info['writable'] = true;
109
+ }
110
+
111
+ if ($infoOptions & self::INFO_SIZE) {
112
+ $info['size'] = 0;
113
+ }
114
+
115
+ $filesystemIterator = new RecursiveIteratorIterator(
116
+ new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::CHILD_FIRST
117
+ );
118
+
119
+ $iterator = new Mage_Backup_Filesystem_Iterator_Filter($filesystemIterator, $skipFiles);
120
+
121
+ foreach ($iterator as $item) {
122
+ if (($infoOptions & self::INFO_WRITABLE) && !$item->isWritable()) {
123
+ $info['writable'] = false;
124
+ }
125
+
126
+ if (($infoOptions & self::INFO_READABLE) && !$item->isReadable()) {
127
+ $info['readable'] = false;
128
+ }
129
+
130
+ if ($infoOptions & self::INFO_SIZE && !$item->isDir()) {
131
+ $info['size'] += $item->getSize();
132
+ }
133
+ }
134
+
135
+ return $info;
136
+ }
137
+ }
downloader/lib/Mage/Backup/Filesystem/Iterator/File.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Backup
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
+ /**
29
+ * File lines iterator
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Backup
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Backup_Filesystem_Iterator_File extends SplFileObject
36
+ {
37
+ /**
38
+ * The statement that was last read during iteration
39
+ *
40
+ * @var string
41
+ */
42
+ protected $_currentStatement = '';
43
+
44
+ /**
45
+ * Return current sql statement
46
+ *
47
+ * @return string
48
+ */
49
+ public function current()
50
+ {
51
+ return $this->_currentStatement;
52
+ }
53
+
54
+ /**
55
+ * Iterate to next sql statement in file
56
+ */
57
+ public function next()
58
+ {
59
+ $this->_currentStatement = '';
60
+ while (!$this->eof()) {
61
+ $line = $this->fgets();
62
+ if (strlen(trim($line))) {
63
+ $this->_currentStatement .= $line;
64
+ if ($this->_isLineLastInCommand($line)) {
65
+ break;
66
+ }
67
+ }
68
+ }
69
+ }
70
+
71
+ /**
72
+ * Return to first statement
73
+ */
74
+ public function rewind()
75
+ {
76
+ parent::rewind();
77
+ $this->next();
78
+ }
79
+
80
+ /**
81
+ * Check whether provided string is comment
82
+ *
83
+ * @param string $line
84
+ * @return bool
85
+ */
86
+ protected function _isComment($line)
87
+ {
88
+ return $line[0] == '#' || substr($line, 0, 2) == '--';
89
+ }
90
+
91
+ /**
92
+ * Check is line a last in sql command
93
+ *
94
+ * @param string $line
95
+ * @return bool
96
+ */
97
+ protected function _isLineLastInCommand($line)
98
+ {
99
+ $cleanLine = trim($line);
100
+ $lineLength = strlen($cleanLine);
101
+
102
+ $returnResult = false;
103
+ if ($lineLength > 0) {
104
+ $lastSymbolIndex = $lineLength - 1;
105
+ if ($cleanLine[$lastSymbolIndex] == ';') {
106
+ $returnResult = true;
107
+ }
108
+ }
109
+
110
+ return $returnResult;
111
+ }
112
+ }
downloader/lib/Mage/Backup/Filesystem/Iterator/Filter.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Backup
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
+ * Filter Iterator
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Backup
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Backup_Filesystem_Iterator_Filter extends FilterIterator
35
+ {
36
+ /**
37
+ * Array that is used for filtering
38
+ *
39
+ * @var array
40
+ */
41
+ protected $_filters;
42
+
43
+ /**
44
+ * Constructor
45
+ *
46
+ * @param Iterator $iterator
47
+ * @param array $filters list of files to skip
48
+ */
49
+ public function __construct(Iterator $iterator, array $filters)
50
+ {
51
+ parent::__construct($iterator);
52
+ $this->_filters = $filters;
53
+ }
54
+
55
+ /**
56
+ * Check whether the current element of the iterator is acceptable
57
+ *
58
+ * @return bool
59
+ */
60
+ public function accept()
61
+ {
62
+ $current = $this->current()->__toString();
63
+ $currentFilename = $this->current()->getFilename();
64
+
65
+ if ($currentFilename == '.' || $currentFilename == '..') {
66
+ return false;
67
+ }
68
+
69
+ foreach ($this->_filters as $filter) {
70
+ if (false !== strpos($current, $filter)) {
71
+ return false;
72
+ }
73
+ }
74
+
75
+ return true;
76
+ }
77
+ }
downloader/lib/Mage/Backup/Filesystem/Rollback/Abstract.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Backup
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
+ * Filesystem rollback workers abstract class
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Backup
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ abstract class Mage_Backup_Filesystem_Rollback_Abstract
35
+ {
36
+ /**
37
+ * Snapshot object
38
+ *
39
+ * @var Mage_Backup_Filesystem
40
+ */
41
+ protected $_snapshot;
42
+
43
+ /**
44
+ * Default worker constructor
45
+ *
46
+ * @param Mage_Backup_Filesystem $snapshotObject
47
+ */
48
+ public function __construct(Mage_Backup_Filesystem $snapshotObject)
49
+ {
50
+ $this->_snapshot = $snapshotObject;
51
+ }
52
+
53
+ /**
54
+ * Main worker's function that makes files rollback
55
+ */
56
+ abstract public function run();
57
+ }
downloader/lib/Mage/Backup/Filesystem/Rollback/Fs.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Backup
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
+ * Rollback worker for rolling back via local filesystem
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Backup
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Backup_Filesystem_Rollback_Fs extends Mage_Backup_Filesystem_Rollback_Abstract
35
+ {
36
+ /**
37
+ * Files rollback implementation via local filesystem
38
+ *
39
+ * @see Mage_Backup_Filesystem_Rollback_Abstract::run()
40
+ * @throws Mage_Exception
41
+ */
42
+ public function run()
43
+ {
44
+ $snapshotPath = $this->_snapshot->getBackupPath();
45
+
46
+ if (!is_file($snapshotPath) || !is_readable($snapshotPath)) {
47
+ throw new Mage_Backup_Exception_CantLoadSnapshot('Cant load snapshot archive');
48
+ }
49
+
50
+ $fsHelper = new Mage_Backup_Filesystem_Helper();
51
+
52
+ $filesInfo = $fsHelper->getInfo(
53
+ $this->_snapshot->getRootDir(),
54
+ Mage_Backup_Filesystem_Helper::INFO_WRITABLE,
55
+ $this->_snapshot->getIgnorePaths()
56
+ );
57
+
58
+ if (!$filesInfo['writable']) {
59
+ throw new Mage_Backup_Exception_NotEnoughPermissions(
60
+ 'Unable to make rollback because not all files are writable'
61
+ );
62
+ }
63
+
64
+ $archiver = new Mage_Archive();
65
+
66
+ /**
67
+ * we need these fake initializations because all magento's files in filesystem will be deleted and autoloader
68
+ * wont be able to load classes that we need for unpacking
69
+ */
70
+ new Mage_Archive_Tar();
71
+ new Mage_Archive_Gz();
72
+ new Mage_Archive_Helper_File('');
73
+ new Mage_Archive_Helper_File_Gz('');
74
+
75
+ $fsHelper->rm($this->_snapshot->getRootDir(), $this->_snapshot->getIgnorePaths());
76
+ $archiver->unpack($snapshotPath, $this->_snapshot->getRootDir());
77
+ }
78
+ }
downloader/lib/Mage/Backup/Filesystem/Rollback/Ftp.php ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Backup
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
+ * Rollback worker for rolling back via ftp
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Backup
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Backup_Filesystem_Rollback_Ftp extends Mage_Backup_Filesystem_Rollback_Abstract
35
+ {
36
+ /**
37
+ * Ftp client
38
+ *
39
+ * @var Mage_System_Ftp
40
+ */
41
+ protected $_ftpClient;
42
+
43
+ /**
44
+ * Files rollback implementation via ftp
45
+ *
46
+ * @see Mage_Backup_Filesystem_Rollback_Abstract::run()
47
+ * @throws Mage_Exception
48
+ */
49
+ public function run()
50
+ {
51
+ $snapshotPath = $this->_snapshot->getBackupPath();
52
+
53
+ if (!is_file($snapshotPath) || !is_readable($snapshotPath)) {
54
+ throw new Mage_Backup_Exception_CantLoadSnapshot('Cant load snapshot archive');
55
+ }
56
+
57
+ $this->_initFtpClient();
58
+ $this->_validateFtp();
59
+
60
+ $tmpDir = $this->_createTmpDir();
61
+ $this->_unpackSnapshot($tmpDir);
62
+
63
+ $fsHelper = new Mage_Backup_Filesystem_Helper();
64
+
65
+ $this->_cleanupFtp();
66
+ $this->_uploadBackupToFtp($tmpDir);
67
+
68
+ $fsHelper->rm($tmpDir, array(), true);
69
+ }
70
+
71
+ /**
72
+ * Initialize ftp client and connect to ftp
73
+ *
74
+ * @throws Mage_Backup_Exception_FtpConnectionFailed
75
+ */
76
+ protected function _initFtpClient()
77
+ {
78
+ try {
79
+ $this->_ftpClient = new Mage_System_Ftp();
80
+ $this->_ftpClient->connect($this->_snapshot->getFtpConnectString());
81
+ } catch (Exception $e) {
82
+ throw new Mage_Backup_Exception_FtpConnectionFailed($e->getMessage());
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Perform ftp validation. Check whether ftp account provided points to current magento installation
88
+ *
89
+ * @throws Mage_Exception
90
+ */
91
+ protected function _validateFtp()
92
+ {
93
+ $validationFilename = '~validation-' . microtime(true) . '.tmp';
94
+ $validationFilePath = $this->_snapshot->getBackupsDir() . DS . $validationFilename;
95
+
96
+ $fh = @fopen($validationFilePath, 'w');
97
+ @fclose($fh);
98
+
99
+ if (!is_file($validationFilePath)) {
100
+ throw new Mage_Exception('Unable to validate ftp account');
101
+ }
102
+
103
+ $rootDir = $this->_snapshot->getRootDir();
104
+ $ftpPath = $this->_snapshot->getFtpPath() . DS . str_replace($rootDir, '', $validationFilePath);
105
+
106
+ $fileExistsOnFtp = $this->_ftpClient->fileExists($ftpPath);
107
+ @unlink($validationFilePath);
108
+
109
+ if (!$fileExistsOnFtp) {
110
+ throw new Mage_Backup_Exception_FtpValidationFailed('Failed to validate ftp account');
111
+ }
112
+ }
113
+
114
+ /**
115
+ * Unpack snapshot
116
+ *
117
+ * @param string $tmpDir
118
+ */
119
+ protected function _unpackSnapshot($tmpDir)
120
+ {
121
+ $snapshotPath = $this->_snapshot->getBackupPath();
122
+
123
+ $archiver = new Mage_Archive();
124
+ $archiver->unpack($snapshotPath, $tmpDir);
125
+ }
126
+
127
+ /**
128
+ * @throws Mage_Exception
129
+ * @return string
130
+ */
131
+ protected function _createTmpDir()
132
+ {
133
+ $tmpDir = $this->_snapshot->getBackupsDir() . DS . '~tmp-' . microtime(true);
134
+
135
+ $result = @mkdir($tmpDir);
136
+
137
+ if (false === $result) {
138
+ throw new Mage_Backup_Exception_NotEnoughPermissions('Failed to create directory ' . $tmpDir);
139
+ }
140
+
141
+ return $tmpDir;
142
+ }
143
+
144
+ /**
145
+ * Delete magento and all files from ftp
146
+ */
147
+ protected function _cleanupFtp()
148
+ {
149
+ $rootDir = $this->_snapshot->getRootDir();
150
+
151
+ $filesystemIterator = new RecursiveIteratorIterator(
152
+ new RecursiveDirectoryIterator($rootDir), RecursiveIteratorIterator::CHILD_FIRST
153
+ );
154
+
155
+ $iterator = new Mage_Backup_Filesystem_Iterator_Filter($filesystemIterator, $this->_snapshot->getIgnorePaths());
156
+
157
+ foreach ($iterator as $item) {
158
+ $ftpPath = $this->_snapshot->getFtpPath() . DS . str_replace($rootDir, '', $item->__toString());
159
+ $ftpPath = str_replace(DS, '/', $ftpPath);
160
+
161
+ $this->_ftpClient->delete($ftpPath);
162
+ }
163
+ }
164
+
165
+ /**
166
+ * Perform files rollback
167
+ *
168
+ * @param string $tmpDir
169
+ * @throws Mage_Exception
170
+ */
171
+ protected function _uploadBackupToFtp($tmpDir)
172
+ {
173
+ $filesystemIterator = new RecursiveIteratorIterator(
174
+ new RecursiveDirectoryIterator($tmpDir), RecursiveIteratorIterator::SELF_FIRST
175
+ );
176
+
177
+ $iterator = new Mage_Backup_Filesystem_Iterator_Filter($filesystemIterator, $this->_snapshot->getIgnorePaths());
178
+
179
+ foreach ($filesystemIterator as $item) {
180
+ $ftpPath = $this->_snapshot->getFtpPath() . DS . str_replace($tmpDir, '', $item->__toString());
181
+ $ftpPath = str_replace(DS, '/', $ftpPath);
182
+
183
+ if ($item->isDir()) {
184
+ $this->_ftpClient->mkdirRecursive($ftpPath);
185
+ } else {
186
+ $result = $this->_ftpClient->put($ftpPath, $item->__toString());
187
+ if (false === $result) {
188
+ throw new Mage_Backup_Exception_NotEnoughPermissions('Failed to upload file '
189
+ . $item->__toString() . ' to ftp');
190
+ }
191
+ }
192
+ }
193
+ }
194
+ }
downloader/lib/Mage/Backup/Interface.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Backup
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
+ * Interface for work with archives
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Backup
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ interface Mage_Backup_Interface
35
+ {
36
+ /**
37
+ * Create Backup
38
+ *
39
+ * @return boolean
40
+ */
41
+ public function create();
42
+
43
+ /**
44
+ * Rollback Backup
45
+ *
46
+ * @return boolean
47
+ */
48
+ public function rollback();
49
+
50
+ /**
51
+ * Set Backup Extension
52
+ *
53
+ * @param string $backupExtension
54
+ * @return Mage_Backup_Interface
55
+ */
56
+ public function setBackupExtension($backupExtension);
57
+
58
+ /**
59
+ * Set Resource Model
60
+ *
61
+ * @param object $resourceModel
62
+ * @return Mage_Backup_Interface
63
+ */
64
+ public function setResourceModel($resourceModel);
65
+
66
+ /**
67
+ * Set Time
68
+ *
69
+ * @param int $time
70
+ * @return Mage_Backup_Interface
71
+ */
72
+ public function setTime($time);
73
+
74
+ /**
75
+ * Get Backup Type
76
+ *
77
+ * @return string
78
+ */
79
+ public function getType();
80
+
81
+ /**
82
+ * Set path to directory where backups stored
83
+ *
84
+ * @param string $backupsDir
85
+ * @return Mage_Backup_Interface
86
+ */
87
+ public function setBackupsDir($backupsDir);
88
+ }
downloader/lib/Mage/Backup/Media.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Backup
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
+ * Class to work media folder and database backups
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Backup
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Backup_Media extends Mage_Backup_Snapshot
35
+ {
36
+ /**
37
+ * Implementation Rollback functionality for Snapshot
38
+ *
39
+ * @throws Mage_Exception
40
+ * @return bool
41
+ */
42
+ public function rollback()
43
+ {
44
+ $this->_prepareIgnoreList();
45
+ return parent::rollback();
46
+ }
47
+
48
+ /**
49
+ * Implementation Create Backup functionality for Snapshot
50
+ *
51
+ * @throws Mage_Exception
52
+ * @return bool
53
+ */
54
+ public function create()
55
+ {
56
+ $this->_prepareIgnoreList();
57
+ return parent::create();
58
+ }
59
+
60
+ /**
61
+ * Overlap getType
62
+ *
63
+ * @return string
64
+ * @see Mage_Backup_Interface::getType()
65
+ */
66
+ public function getType()
67
+ {
68
+ return 'media';
69
+ }
70
+
71
+ /**
72
+ * Add all folders and files except media and db backup to ignore list
73
+ *
74
+ * @return Mage_Backup_Media
75
+ */
76
+ protected function _prepareIgnoreList()
77
+ {
78
+ $iterator = new DirectoryIterator($this->getRootDir());
79
+
80
+ foreach ($iterator as $item) {
81
+ $filename = $item->getFilename();
82
+ if (!in_array($filename, array('media', 'var'))) {
83
+ $this->addIgnorePaths($item->getPathname());
84
+ }
85
+ }
86
+
87
+ $iterator = new DirectoryIterator($this->getRootDir() . DS . 'var');
88
+ $dbBackupFilename = $this->_getDbBackupManager()->getBackupFilename();
89
+
90
+ foreach ($iterator as $item) {
91
+ $filename = $item->getFilename();
92
+ if ($filename != $dbBackupFilename) {
93
+ $this->addIgnorePaths($item->getPathname());
94
+ }
95
+ }
96
+
97
+ return $this;
98
+ }
99
+ }
downloader/lib/Mage/Backup/Nomedia.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Backup
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
+ * Class to work system backup that excludes media folder
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Backup
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Backup_Nomedia extends Mage_Backup_Snapshot
35
+ {
36
+ /**
37
+ * Implementation Rollback functionality for Snapshot
38
+ *
39
+ * @throws Mage_Exception
40
+ * @return bool
41
+ */
42
+ public function rollback()
43
+ {
44
+ $this->_prepareIgnoreList();
45
+ return parent::rollback();
46
+ }
47
+
48
+ /**
49
+ * Implementation Create Backup functionality for Snapshot
50
+ *
51
+ * @throws Mage_Exception
52
+ * @return bool
53
+ */
54
+ public function create()
55
+ {
56
+ $this->_prepareIgnoreList();
57
+ return parent::create();
58
+ }
59
+
60
+ /**
61
+ * Overlap getType
62
+ *
63
+ * @return string
64
+ * @see Mage_Backup_Interface::getType()
65
+ */
66
+ public function getType()
67
+ {
68
+ return 'nomedia';
69
+ }
70
+
71
+ /**
72
+ * Add media folder to ignore list
73
+ *
74
+ * @return Mage_Backup_Media
75
+ */
76
+ protected function _prepareIgnoreList()
77
+ {
78
+ $this->addIgnorePaths($this->getRootDir() . DS . 'media');
79
+
80
+ return $this;
81
+ }
82
+ }
downloader/lib/Mage/Backup/Snapshot.php ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Backup
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
+ * Class to work with full filesystem and database backups
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Backup
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Backup_Snapshot extends Mage_Backup_Filesystem
35
+ {
36
+ /**
37
+ * Database backup manager
38
+ *
39
+ * @var Mage_Backup_Db
40
+ */
41
+ protected $_dbBackupManager;
42
+
43
+ /**
44
+ * Implementation Rollback functionality for Snapshot
45
+ *
46
+ * @throws Mage_Exception
47
+ * @return bool
48
+ */
49
+ public function rollback()
50
+ {
51
+ $result = parent::rollback();
52
+
53
+ $this->_lastOperationSucceed = false;
54
+
55
+ try {
56
+ $this->_getDbBackupManager()->rollback();
57
+ } catch (Exception $e) {
58
+ $this->_removeDbBackup();
59
+ throw $e;
60
+ }
61
+
62
+ $this->_removeDbBackup();
63
+ $this->_lastOperationSucceed = true;
64
+
65
+ return $result;
66
+ }
67
+
68
+ /**
69
+ * Implementation Create Backup functionality for Snapshot
70
+ *
71
+ * @throws Mage_Exception
72
+ * @return bool
73
+ */
74
+ public function create()
75
+ {
76
+ $this->_getDbBackupManager()->create();
77
+
78
+ try {
79
+ $result = parent::create();
80
+ } catch (Exception $e) {
81
+ $this->_removeDbBackup();
82
+ throw $e;
83
+ }
84
+
85
+ $this->_lastOperationSucceed = false;
86
+ $this->_removeDbBackup();
87
+ $this->_lastOperationSucceed = true;
88
+
89
+ return $result;
90
+ }
91
+
92
+ /**
93
+ * Overlap getType
94
+ *
95
+ * @return string
96
+ * @see Mage_Backup_Interface::getType()
97
+ */
98
+ public function getType()
99
+ {
100
+ return 'snapshot';
101
+ }
102
+
103
+ /**
104
+ * Create Db Instance
105
+ *
106
+ * @return Mage_Backup_Interface
107
+ */
108
+ protected function _createDbBackupInstance()
109
+ {
110
+ return Mage_Backup::getBackupInstance(Mage_Backup_Helper_Data::TYPE_DB)
111
+ ->setBackupExtension(Mage::helper('backup')->getExtensionByType(Mage_Backup_Helper_Data::TYPE_DB))
112
+ ->setTime($this->getTime())
113
+ ->setBackupsDir(Mage::getBaseDir("var"))
114
+ ->setResourceModel($this->getResourceModel());
115
+ }
116
+
117
+ /**
118
+ * Get database backup manager
119
+ *
120
+ * @return Mage_Backup_Db
121
+ */
122
+ protected function _getDbBackupManager()
123
+ {
124
+ if (is_null($this->_dbBackupManager)) {
125
+ $this->_dbBackupManager = $this->_createDbBackupInstance();
126
+ }
127
+
128
+ return $this->_dbBackupManager;
129
+ }
130
+
131
+ /**
132
+ * Remove Db backup after added it to the snapshot
133
+ *
134
+ * @return Mage_Backup_Snapshot
135
+ */
136
+ protected function _removeDbBackup(){
137
+ @unlink($this->_getDbBackupManager()->getBackupPath());
138
+ return $this;
139
+ }
140
+ }
downloader/lib/Mage/Connect/Channel/Generator.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/Connect/Channel/Parser.php CHANGED
@@ -20,6 +20,6 @@
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
  */
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
  */
downloader/lib/Mage/Connect/Channel/VO.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/Connect/Command.php CHANGED
@@ -20,11 +20,17 @@
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
 
27
-
 
 
 
 
 
 
28
  class Mage_Connect_Command
29
  {
30
  /**
@@ -44,21 +50,51 @@ class Mage_Connect_Command
44
  * @var Mage_Connect_Fro
45
  */
46
  protected static $_frontend = null;
 
 
 
 
 
47
  protected static $_config = null;
48
- protected static $_registry = null;
 
 
 
 
49
  protected static $_validator = null;
 
 
 
 
 
 
50
  protected static $_rest = null;
 
 
 
 
 
 
51
  protected static $_sconfig = null;
52
 
53
- protected $_data;
 
 
 
 
54
  protected $_class;
 
 
 
 
 
 
55
  protected static $_packager = null;
56
 
57
  protected static $_return = array();
58
 
59
  /**
60
  * Constructor
61
- *
62
  */
63
  public function __construct()
64
  {
@@ -69,11 +105,11 @@ class Mage_Connect_Command
69
  $this->commandsInfo = self::$_commandsByClass[$class];
70
  }
71
 
72
-
73
  /**
74
  * Get command info (static)
 
75
  * @param string $name command name
76
- * @return array/bool
77
  */
78
  public static function commandInfo($name)
79
  {
@@ -86,10 +122,10 @@ class Mage_Connect_Command
86
 
87
  /**
88
  * Get command info for current command object
 
89
  * @param string $name
90
- * @return array/bool
91
  */
92
-
93
  public function getCommandInfo($name)
94
  {
95
  if(!isset(self::$_commandsByClass[$this->_class][$name])) {
@@ -100,6 +136,7 @@ class Mage_Connect_Command
100
 
101
  /**
102
  * Run command
 
103
  * @param string $command
104
  * @param string $options
105
  * @param string $params
@@ -134,47 +171,53 @@ class Mage_Connect_Command
134
  return new $currentCommand['class']();
135
  }
136
 
137
-
 
 
 
 
 
 
138
  public static function setSconfig($obj)
139
  {
140
  self::$_sconfig = $obj;
141
  }
142
-
143
  /**
144
- *
 
145
  * @return Mage_Connect_Singleconfig
146
  */
147
  public function getSconfig()
148
  {
149
  return self::$_sconfig;
150
  }
151
-
152
-
153
  /**
154
  * Sets frontend object for all commands
155
  *
156
  * @param Mage_Connect_Frontend $obj
157
- * @return void
158
  */
159
  public static function setFrontendObject($obj)
160
  {
161
  self::$_frontend = $obj;
162
  }
163
 
164
-
165
  /**
166
  * Set config object for all commands
 
167
  * @param Mage_Connect_Config $obj
168
- * @return void
169
  */
170
  public static function setConfigObject($obj)
171
  {
172
  self::$_config = $obj;
173
  }
174
 
175
-
176
  /**
177
  * Non-static getter for config
 
178
  * @return Mage_Connect_Config
179
  */
180
  public function config()
@@ -184,6 +227,7 @@ class Mage_Connect_Command
184
 
185
  /**
186
  * Non-static getter for UI
 
187
  * @return Mage_Connect_Frontend
188
  */
189
  public function ui()
@@ -191,9 +235,9 @@ class Mage_Connect_Command
191
  return self::$_frontend;
192
  }
193
 
194
-
195
  /**
196
  * Get validator object
 
197
  * @return Mage_Connect_Validator
198
  */
199
  public function validator()
@@ -206,6 +250,7 @@ class Mage_Connect_Command
206
 
207
  /**
208
  * Get rest object
 
209
  * @return Mage_Connect_Rest
210
  */
211
  public function rest()
@@ -216,9 +261,9 @@ class Mage_Connect_Command
216
  return self::$_rest;
217
  }
218
 
219
-
220
  /**
221
  * Get commands list sorted
 
222
  * @return array
223
  */
224
  public static function getCommands()
@@ -230,10 +275,10 @@ class Mage_Connect_Command
230
  return self::$_commandsAll;
231
  }
232
 
233
-
234
  /**
235
  * Get Getopt args from command definitions
236
  * and parse them
 
237
  * @param $command
238
  * @return array
239
  */
@@ -252,11 +297,9 @@ class Mage_Connect_Command
252
  if ($info['arg']{0} == '(') {
253
  $larg = '==';
254
  $sarg = '::';
255
- $arg = substr($info['arg'], 1, -1);
256
  } else {
257
  $larg = '=';
258
  $sarg = ':';
259
- $arg = $info['arg'];
260
  }
261
  }
262
  if (isset($info['shortopt'])) {
@@ -269,13 +312,15 @@ class Mage_Connect_Command
269
 
270
  /**
271
  * Try to register commands automatically
272
- * @return void
 
273
  */
274
  public static function registerCommands()
275
  {
276
  $pathCommands = dirname(__FILE__).DIRECTORY_SEPARATOR.basename(__FILE__, ".php");
277
  $f = new DirectoryIterator($pathCommands);
278
  foreach($f as $file) {
 
279
  if (! $file->isFile()) {
280
  continue;
281
  }
@@ -296,17 +341,24 @@ class Mage_Connect_Command
296
  }
297
  }
298
 
 
 
 
 
 
 
 
299
  public function doError($command, $message)
300
  {
301
  return $this->ui()->doError($command, $message);
302
  }
303
 
304
-
305
  /**
306
  * Set command return
 
307
  * @param string $key
308
  * @param mixed $val
309
- * @return void
310
  */
311
  public static function setReturn($key, $val)
312
  {
@@ -315,6 +367,7 @@ class Mage_Connect_Command
315
 
316
  /**
317
  * Get command return
 
318
  * @param $key
319
  * @param $clear
320
  * @return mixed
@@ -342,7 +395,7 @@ class Mage_Connect_Command
342
  if(!count($params)) {
343
  return;
344
  }
345
- foreach($params as $k=>$v) {
346
  if(is_string($v)) {
347
  $v = trim($v);
348
  if(!strlen($v)) {
@@ -374,17 +427,17 @@ class Mage_Connect_Command
374
  }
375
  }
376
 
377
-
378
  /**
379
  * Get packager instance
380
- * @return Mage_Connect_Pacakger
 
381
  */
382
- public function getPackager()
383
  {
384
  if(!self::$_packager) {
385
  self::$_packager = new Mage_Connect_Packager();
386
  }
387
- return self::$_packager;
388
  }
389
-
390
  }
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
 
27
+ /**
28
+ * Connect Command abstract class. It cannot instantiate directly
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Connect
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
  class Mage_Connect_Command
35
  {
36
  /**
50
  * @var Mage_Connect_Fro
51
  */
52
  protected static $_frontend = null;
53
+
54
+ /**
55
+ * Connect Config instance
56
+ * @var Mage_Connect_Config
57
+ */
58
  protected static $_config = null;
59
+ /**
60
+ * Validator instance
61
+ *
62
+ * @var Mage_Connect_Validator
63
+ */
64
  protected static $_validator = null;
65
+
66
+ /**
67
+ * Rest instance
68
+ *
69
+ * @var Mage_Connect_Rest
70
+ */
71
  protected static $_rest = null;
72
+
73
+ /**
74
+ * Cache config instance
75
+ *
76
+ * @var Mage_Connect_Singleconfig
77
+ */
78
  protected static $_sconfig = null;
79
 
80
+ /**
81
+ * Called class name
82
+ *
83
+ * @var string
84
+ */
85
  protected $_class;
86
+
87
+ /**
88
+ * Packager instance
89
+ *
90
+ * @var Mage_Connect_Packager
91
+ */
92
  protected static $_packager = null;
93
 
94
  protected static $_return = array();
95
 
96
  /**
97
  * Constructor
 
98
  */
99
  public function __construct()
100
  {
105
  $this->commandsInfo = self::$_commandsByClass[$class];
106
  }
107
 
 
108
  /**
109
  * Get command info (static)
110
+ *
111
  * @param string $name command name
112
+ * @return array|boolean
113
  */
114
  public static function commandInfo($name)
115
  {
122
 
123
  /**
124
  * Get command info for current command object
125
+ *
126
  * @param string $name
127
+ * @return array|boolean
128
  */
 
129
  public function getCommandInfo($name)
130
  {
131
  if(!isset(self::$_commandsByClass[$this->_class][$name])) {
136
 
137
  /**
138
  * Run command
139
+ *
140
  * @param string $command
141
  * @param string $options
142
  * @param string $params
171
  return new $currentCommand['class']();
172
  }
173
 
174
+ /**
175
+ * Cache config setter
176
+ *
177
+ * @static
178
+ * @param Mage_Connect_Singleconfig $obj
179
+ * @return null
180
+ */
181
  public static function setSconfig($obj)
182
  {
183
  self::$_sconfig = $obj;
184
  }
185
+
186
  /**
187
+ * Cache config getter
188
+ *
189
  * @return Mage_Connect_Singleconfig
190
  */
191
  public function getSconfig()
192
  {
193
  return self::$_sconfig;
194
  }
195
+
 
196
  /**
197
  * Sets frontend object for all commands
198
  *
199
  * @param Mage_Connect_Frontend $obj
200
+ * @return null
201
  */
202
  public static function setFrontendObject($obj)
203
  {
204
  self::$_frontend = $obj;
205
  }
206
 
 
207
  /**
208
  * Set config object for all commands
209
+ *
210
  * @param Mage_Connect_Config $obj
211
+ * @return null
212
  */
213
  public static function setConfigObject($obj)
214
  {
215
  self::$_config = $obj;
216
  }
217
 
 
218
  /**
219
  * Non-static getter for config
220
+ *
221
  * @return Mage_Connect_Config
222
  */
223
  public function config()
227
 
228
  /**
229
  * Non-static getter for UI
230
+ *
231
  * @return Mage_Connect_Frontend
232
  */
233
  public function ui()
235
  return self::$_frontend;
236
  }
237
 
 
238
  /**
239
  * Get validator object
240
+ *
241
  * @return Mage_Connect_Validator
242
  */
243
  public function validator()
250
 
251
  /**
252
  * Get rest object
253
+ *
254
  * @return Mage_Connect_Rest
255
  */
256
  public function rest()
261
  return self::$_rest;
262
  }
263
 
 
264
  /**
265
  * Get commands list sorted
266
+ *
267
  * @return array
268
  */
269
  public static function getCommands()
275
  return self::$_commandsAll;
276
  }
277
 
 
278
  /**
279
  * Get Getopt args from command definitions
280
  * and parse them
281
+ *
282
  * @param $command
283
  * @return array
284
  */
297
  if ($info['arg']{0} == '(') {
298
  $larg = '==';
299
  $sarg = '::';
 
300
  } else {
301
  $larg = '=';
302
  $sarg = ':';
 
303
  }
304
  }
305
  if (isset($info['shortopt'])) {
312
 
313
  /**
314
  * Try to register commands automatically
315
+ *
316
+ * @return null
317
  */
318
  public static function registerCommands()
319
  {
320
  $pathCommands = dirname(__FILE__).DIRECTORY_SEPARATOR.basename(__FILE__, ".php");
321
  $f = new DirectoryIterator($pathCommands);
322
  foreach($f as $file) {
323
+ /** @var $file DirectoryIterator */
324
  if (! $file->isFile()) {
325
  continue;
326
  }
341
  }
342
  }
343
 
344
+ /**
345
+ * Add Error message
346
+ *
347
+ * @param string $command
348
+ * @param string $message
349
+ * @return null
350
+ */
351
  public function doError($command, $message)
352
  {
353
  return $this->ui()->doError($command, $message);
354
  }
355
 
 
356
  /**
357
  * Set command return
358
+ *
359
  * @param string $key
360
  * @param mixed $val
361
+ * @return null
362
  */
363
  public static function setReturn($key, $val)
364
  {
367
 
368
  /**
369
  * Get command return
370
+ *
371
  * @param $key
372
  * @param $clear
373
  * @return mixed
395
  if(!count($params)) {
396
  return;
397
  }
398
+ foreach($params as $v) {
399
  if(is_string($v)) {
400
  $v = trim($v);
401
  if(!strlen($v)) {
427
  }
428
  }
429
 
430
+
431
  /**
432
  * Get packager instance
433
+ *
434
+ * @return Mage_Connect_Packager
435
  */
436
+ public function getPackager()
437
  {
438
  if(!self::$_packager) {
439
  self::$_packager = new Mage_Connect_Packager();
440
  }
441
+ return self::$_packager;
442
  }
 
443
  }
downloader/lib/Mage/Connect/Command/Channels.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/Connect/Command/Channels_Header.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/Connect/Command/Config.php CHANGED
@@ -20,19 +20,26 @@
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
 
27
-
28
- class Mage_Connect_Command_Config
29
- extends Mage_Connect_Command
30
-
 
 
 
 
 
31
  {
 
 
 
32
  const PARAM_KEY = 0;
33
  const PARAM_VAL = 1;
34
 
35
-
36
  /**
37
  * Show config variable
38
  * @param string $command
@@ -70,7 +77,6 @@ extends Mage_Connect_Command
70
  }
71
  }
72
 
73
-
74
  /**
75
  * Set config variable
76
  * @param string $command
@@ -207,7 +213,4 @@ extends Mage_Connect_Command
207
  return $this->doError($command, $e->getMessage());
208
  }
209
  }
210
-
211
  }
212
-
213
-
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
 
27
+ /**
28
+ * Configuration command callbacks
29
+ *
30
+ * @throws Exception
31
+ * @category Mage
32
+ * @package Mage_Connect
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Connect_Command_Config extends Mage_Connect_Command
36
  {
37
+ /**
38
+ * Parameters constants
39
+ */
40
  const PARAM_KEY = 0;
41
  const PARAM_VAL = 1;
42
 
 
43
  /**
44
  * Show config variable
45
  * @param string $command
77
  }
78
  }
79
 
 
80
  /**
81
  * Set config variable
82
  * @param string $command
213
  return $this->doError($command, $e->getMessage());
214
  }
215
  }
 
216
  }
 
 
downloader/lib/Mage/Connect/Command/Config_Header.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/Connect/Command/Install.php CHANGED
@@ -20,21 +20,20 @@
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
-
27
-
28
- final class Mage_Connect_Command_Install
29
- extends Mage_Connect_Command
30
  {
31
-
32
  /**
33
  * Install action callback
 
 
34
  * @param string $command
35
  * @param array $options
36
  * @param array $params
37
- * @return void
 
38
  */
39
  public function doInstall($command, $options, $params, $objects = array())
40
  {
@@ -42,16 +41,21 @@ extends Mage_Connect_Command
42
 
43
  $installFileMode = $command === 'install-file';
44
 
45
-
46
- $cache=null;
47
- /**
48
- * @var $cache Mage_Connect_Singleconfig
49
- */
50
  $ftpObj=null;
51
-
 
 
 
 
 
 
 
 
 
 
52
 
53
  try {
54
- $packager = $this->getPackager();
55
  $forceMode = isset($options['force']);
56
  $upgradeAllMode = $command == 'upgrade-all';
57
  $upgradeMode = $command == 'upgrade' || $command == 'upgrade-all';
@@ -63,14 +67,7 @@ extends Mage_Connect_Command
63
  $channelAuth = isset($options['auth'])?$options['auth']:array();
64
 
65
  $rest = $this->rest();
66
- $ftp = empty($options['ftp']) ? false : $options['ftp'];
67
- if($ftp) {
68
- list($cache, $config, $ftpObj) = $packager->getRemoteConf($ftp);
69
- } else {
70
- $config = $this->config();
71
- $cache = $this->getSconfig();
72
- }
73
- if(empty($config->magento_root)){
74
  $config->magento_root=dirname(dirname($_SERVER['SCRIPT_FILENAME']));
75
  }
76
  chdir($config->magento_root);
@@ -79,7 +76,7 @@ extends Mage_Connect_Command
79
  $dirTmp = DIRECTORY_SEPARATOR . Mage_Connect_Package_Reader::PATH_TO_TEMPORARY_DIRECTORY;
80
  $dirMedia = DIRECTORY_SEPARATOR . 'media';
81
  $isWritable = true;
82
- if($ftp) {
83
  $cwd=$ftpObj->getcwd();
84
  $ftpObj->mkdirRecursive($cwd . $dirCache,0777);
85
  $ftpObj->chdir($cwd);
@@ -102,25 +99,25 @@ extends Mage_Connect_Command
102
  $isWritable = $isWritable && is_writable($config->magento_root . $dirMedia)
103
  && is_writable($config->magento_root . $dirCache)
104
  && is_writable($config->magento_root . $dirTmp);
105
- if(!$isWritable){
106
  $this->doError($command, $err);
107
  throw new Exception(
108
  'Your Magento folder does not have sufficient write permissions, which downloader requires.'
109
  );
110
  }
111
- if(!empty($channelAuth)){
112
  $rest->getLoader()->setCredentials($channelAuth['username'], $channelAuth['password']);
113
  }
114
 
115
- if($installFileMode) {
116
- if(count($params) < 1) {
117
  throw new Exception("Argument should be: filename");
118
  }
119
  $filename = $params[0];
120
- if(!@file_exists($filename)) {
121
  throw new Exception("File '{$filename}' not found");
122
  }
123
- if(!@is_readable($filename)) {
124
  throw new Exception("File '{$filename}' is not readable");
125
  }
126
 
@@ -128,15 +125,14 @@ extends Mage_Connect_Command
128
  $package->setConfig($config);
129
  $package->validate();
130
  $errors = $package->getErrors();
131
- if(count($errors)) {
132
- throw new Exception("Package file is invalid\n".implode("\n", $errors));
133
  }
134
 
135
  $pChan = $package->getChannel();
136
  $pName = $package->getName();
137
  $pVer = $package->getVersion();
138
 
139
-
140
  if (!($cache->isChannelName($pChan) || $cache->isChannelAlias($pChan))) {
141
  throw new Exception("The '{$pChan}' channel is not installed. Please use the MAGE shell "
142
  . "script to install the '{$pChan}' channel.");
@@ -144,20 +140,20 @@ extends Mage_Connect_Command
144
 
145
  $conflicts = $cache->hasConflicts($pChan, $pName, $pVer);
146
 
147
- if(false !== $conflicts) {
148
  $conflicts = implode(", ",$conflicts);
149
- if($forceMode) {
150
- $this->doError($command, "Package {$pChan}/{$pName} {$pVer} conflicts with: ".$conflicts);
151
  } else {
152
- throw new Exception("Package {$pChan}/{$pName} {$pVer} conflicts with: ".$conflicts);
153
  }
154
  }
155
 
156
  $conflicts = $package->checkPhpDependencies();
157
- if(true !== $conflicts) {
158
- $confilcts = implode(",",$conflicts);
159
- $err = "Package {$pChan}/{$pName} {$pVer} depends on PHP extensions: ".$conflicts;
160
- if($forceMode) {
161
  $this->doError($command, $err);
162
  } else {
163
  throw new Exception($err);
@@ -165,18 +161,17 @@ extends Mage_Connect_Command
165
  }
166
 
167
  $conflicts = $package->checkPhpVersion();
168
- if(true !== $conflicts) {
169
- $err = "Package {$pChan}/{$pName} {$pVer}: ".$conflicts;
170
- if($forceMode) {
171
  $this->doError($command, $err);
172
  } else {
173
  throw new Exception($err);
174
  }
175
  }
176
 
177
-
178
- if(!$noFilesInstall) {
179
- if($ftp) {
180
  $packager->processInstallPackageFtp($package, $filename, $config, $ftpObj);
181
  } else {
182
  $packager->processInstallPackage($package, $filename, $config);
@@ -188,11 +183,10 @@ extends Mage_Connect_Command
188
  $installedDepsAssoc[] = array('channel'=>$pChan, 'name'=>$pName, 'version'=>$pVer);
189
  $installedDeps[] = array($pChan, $pName, $pVer);
190
 
191
-
192
  $title = isset($options['title']) ? $options['title'] : "Package installed: ";
193
  $out = array($command => array('data'=>$installedDeps, 'assoc'=>$installedDepsAssoc, 'title'=>$title));
194
 
195
- if($ftp) {
196
  $packager->writeToRemoteCache($cache, $ftpObj);
197
  @unlink($config->getFilename());
198
  }
@@ -201,9 +195,8 @@ extends Mage_Connect_Command
201
  return $out[$command]['data'];
202
  }
203
 
204
- if(!$upgradeAllMode) {
205
-
206
- if(count($params) < 2) {
207
  throw new Exception("Argument should be: channelName packageName");
208
  }
209
  $channel = $params[0];
@@ -220,44 +213,37 @@ extends Mage_Connect_Command
220
  /*
221
  * process 'failed' results
222
  */
223
- if(count($packagesToInstall['failed'])) {
224
  $showError=!count($packagesToInstall['result']);
225
- foreach($packagesToInstall['failed'] as $failed){
226
- //$failed = array(
227
- // 'name'=>$package,
228
- // 'channel'=>$chanName,
229
- // 'max'=>$versionMax,
230
- // 'min'=>$versionMin,
231
- // 'reason'=>$e->getMessage()
232
- //);
233
- $msg="Package {$failed['channel']}/{$failed['name']} failed: ".$failed['reason'];
234
- if($showError){
235
  $this->doError($command, $msg);
236
- }else{
237
  $this->ui()->output($msg);
238
  }
239
  }
240
  }
241
  $packagesToInstall = $packagesToInstall['result'];
242
  } else {
243
- if(empty($params[0])) {
244
  $channels = $cache->getChannelNames();
245
  } else {
246
  $channel = $params[0];
247
- if(!$cache->isChannel($channel)) {
248
  throw new Exception("'{$channel}' is not existant channel name / valid uri");
249
  }
250
  $channels = $cache->chanName($channel);
251
  }
252
  $packagesToInstall = array();
253
  $neededToUpgrade = $packager->getUpgradesList($channels, $cache, $config, $rest);
254
- foreach($neededToUpgrade as $chan=>$packages) {
255
- foreach($packages as $name=>$data) {
256
  $versionTo = $data['to'];
257
  $tmp = $packager->getDependenciesList($chan, $name, $cache, $config, $versionTo, $versionTo,
258
  $withDepsMode, false, $rest
259
  );
260
- if(count($tmp['result'])) {
261
  $packagesToInstall = array_merge($packagesToInstall, $tmp['result']);
262
  }
263
  }
@@ -269,9 +255,8 @@ extends Mage_Connect_Command
269
  */
270
  $installedDeps = array();
271
  $installedDepsAssoc = array();
272
- $keys = array();
273
 
274
- foreach($packagesToInstall as $package) {
275
  try {
276
  $pName = $package['name'];
277
  $pChan = $package['channel'];
@@ -289,7 +274,7 @@ extends Mage_Connect_Command
289
  continue;
290
  }
291
 
292
- if('incompartible' == $pInstallState) {
293
  $this->ui()->output(
294
  "Package incompartible with installed Magento: {$pChan}/{$pName} {$pVer}, skipping"
295
  );
@@ -298,12 +283,12 @@ extends Mage_Connect_Command
298
 
299
  $conflicts = $cache->hasConflicts($pChan, $pName, $pVer);
300
 
301
- if(false !== $conflicts) {
302
  $conflicts = implode(", ",$conflicts);
303
- if($forceMode) {
304
- $this->doError($command, "Package {$pChan}/{$pName} {$pVer} conflicts with: ".$conflicts);
305
  } else {
306
- throw new Exception("Package {$pChan}/{$pName} {$pVer} conflicts with: ".$conflicts);
307
  }
308
  }
309
 
@@ -311,7 +296,7 @@ extends Mage_Connect_Command
311
  * Modifications
312
  */
313
  if (($upgradeMode || ($pInstallState == 'upgrade')) && !$ignoreModifiedMode) {
314
- if($ftp) {
315
  $modifications = $packager->getRemoteModifiedFiles($pChan, $pName, $cache, $config, $ftp);
316
  } else {
317
  $modifications = $packager->getLocalModifiedFiles($pChan, $pName, $cache, $config);
@@ -319,18 +304,16 @@ extends Mage_Connect_Command
319
  if (count($modifications) > 0) {
320
  $this->ui()->output('Changed locally: ');
321
  foreach ($modifications as $row) {
322
- if(!$ftp) {
323
- $this->ui()->output($config->magento_root.DS.$row);
324
  } else {
325
  $this->ui()->output($row);
326
  }
327
  }
328
- /*$this->ui()->confirm('Do you want rewrite all files?');
329
- continue;*/
330
  }
331
  }
332
 
333
- if($ftp) {
334
  $cwd=$ftpObj->getcwd();
335
  $dir=$cwd . DIRECTORY_SEPARATOR .$config->downloader_path . DIRECTORY_SEPARATOR
336
  . Mage_Connect_Config::DEFAULT_CACHE_PATH . DIRECTORY_SEPARATOR . trim( $pChan, "\\/");
@@ -341,9 +324,9 @@ extends Mage_Connect_Command
341
  @mkdir($dir, 0777, true);
342
  }
343
  $dir = $config->getChannelCacheDir($pChan);
344
- $packageFileName = $pName."-".$pVer.".tgz";
345
- $file = $dir.DIRECTORY_SEPARATOR.$packageFileName;
346
- if(!@file_exists($file)) {
347
  $this->ui()->output("Starting to download $packageFileName ...");
348
  $rest->downloadPackageFileOfRelease($pName, $pVer, $file);
349
  $this->ui()->output(sprintf("...done: %s bytes", number_format(filesize($file))));
@@ -371,10 +354,10 @@ extends Mage_Connect_Command
371
  }
372
 
373
  $conflicts = $package->checkPhpDependencies();
374
- if(true !== $conflicts) {
375
- $confilcts = implode(",",$conflicts);
376
- $err = "Package {$pChan}/{$pName} {$pVer} depends on PHP extensions: ".$conflicts;
377
- if($forceMode) {
378
  $this->doError($command, $err);
379
  } else {
380
  throw new Exception($err);
@@ -382,21 +365,18 @@ extends Mage_Connect_Command
382
  }
383
 
384
  $conflicts = $package->checkPhpVersion();
385
- if(true !== $conflicts) {
386
- $err = "Package {$pChan}/{$pName} {$pVer}: ".$conflicts;
387
- if($forceMode) {
388
  $this->doError($command, $err);
389
  } else {
390
  throw new Exception($err);
391
  }
392
  }
393
 
394
- /**
395
- * @todo: make "Use custom permissions" functionality working
396
- */
397
- if(!$noFilesInstall) {
398
  $this->ui()->output("Installing package {$pChan}/{$pName} {$pVer}");
399
- if($ftp) {
400
  $packager->processInstallPackageFtp($package, $file, $config, $ftpObj);
401
  } else {
402
  $packager->processInstallPackage($package, $file, $config);
@@ -413,21 +393,18 @@ extends Mage_Connect_Command
413
  }
414
  }
415
 
416
-
417
-
418
  $title = isset($options['title']) ? $options['title'] : "Package installed: ";
419
  $out = array($command => array('data'=>$installedDeps, 'assoc'=>$installedDepsAssoc, 'title'=>$title));
420
 
421
- if($ftp) {
422
  $packager->writeToRemoteCache($cache, $ftpObj);
423
  @unlink($config->getFilename());
424
  }
425
 
426
  $this->ui()->output($out);
427
  return $out[$command]['data'];
428
-
429
  } catch (Exception $e) {
430
- if($ftp) {
431
  $packager->writeToRemoteCache($cache, $ftpObj);
432
  @unlink($config->getFilename());
433
  }
@@ -437,10 +414,11 @@ extends Mage_Connect_Command
437
 
438
  /**
439
  * Upgrade action callback
 
440
  * @param string $command
441
  * @param array $options
442
  * @param array $params
443
- * @return void
444
  */
445
  public function doUpgrade($command, $options, $params)
446
  {
@@ -450,10 +428,11 @@ extends Mage_Connect_Command
450
 
451
  /**
452
  * Updgrade action callback
 
453
  * @param string $command
454
  * @param array $options
455
  * @param array $params
456
- * @return void
457
  */
458
  public function doUpgradeAll($command, $options, $params)
459
  {
@@ -463,78 +442,81 @@ extends Mage_Connect_Command
463
 
464
  /**
465
  * Uninstall package callback
 
466
  * @param string $command
467
  * @param array $options
468
  * @param array $params
469
- * @return unknown_type
470
  */
471
  public function doUninstall($command, $options, $params)
472
  {
473
  $this->cleanupParams($params);
474
- //$this->splitPackageArgs($params);
475
 
476
  try {
477
- if(count($params) != 2) {
478
  throw new Exception("Argument count should be = 2");
479
  }
480
 
481
  $channel = $params[0];
482
  $package = $params[1];
 
483
  $packager = $this->getPackager();
484
- $withDepsMode = !isset($options['nodeps']);
485
  $forceMode = isset($options['force']);
486
 
487
  $ftp = empty($options['ftp']) ? false : $options['ftp'];
488
- if($ftp) {
 
 
 
489
  list($cache, $config, $ftpObj) = $packager->getRemoteConf($ftp);
490
  } else {
491
  $cache = $this->getSconfig();
492
  $config = $this->config();
493
  }
494
 
495
- $chan = $cache->getChannel($channel);
496
  $channel = $cache->chanName($channel);
497
- if(!$cache->hasPackage($channel, $package)) {
498
  throw new Exception("Package is not installed");
499
  }
500
 
501
  $deletedPackages = array();
502
  $list = $packager->getUninstallList($channel, $package, $cache, $config, $withDepsMode);
503
- foreach($list['list'] as $packageData) {
504
  try {
505
  $reqd = $cache->requiredByOtherPackages(
506
  $packageData['channel'],
507
  $packageData['name'],
508
  $list['list']
509
  );
510
- if(count($reqd)) {
511
  $errMessage = "{$packageData['channel']}/{$packageData['name']} "
512
  . "{$packageData['version']} is required by: ";
513
  $t = array();
514
- foreach($reqd as $r) {
515
- $t[] = $r['channel']."/".$r['name']. " ".$r['version'];
516
  }
517
  $errMessage .= implode(", ", $t);
518
- if($forceMode) {
519
- $this->ui()->output("Warning: ".$errMessage);
520
  } else {
521
  throw new Exception($errMessage);
522
  }
523
  }
524
  } catch(Exception $e) {
525
- if($forceMode) {
526
  $this->doError($command, $e->getMessage());
527
  } else {
528
  throw new Exception($e->getMessage());
529
  }
530
  }
531
  }
532
- foreach($list['list'] as $packageData) {
533
  try {
534
  list($chan, $pack) = array($packageData['channel'], $packageData['name']);
535
  $packageName = $packageData['channel'] . "/" . $packageData['name'];
536
  $this->ui()->output("Starting to uninstall $packageName ");
537
- if($ftp) {
538
  $packager->processUninstallPackageFtp($chan, $pack, $cache, $ftpObj);
539
  } else {
540
  $packager->processUninstallPackage($chan, $pack, $cache, $config);
@@ -543,25 +525,22 @@ extends Mage_Connect_Command
543
  $deletedPackages[] = array($chan, $pack);
544
  $this->ui()->output("Package {$packageName} uninstalled");
545
  } catch(Exception $e) {
546
- if($forceMode) {
547
  $this->doError($command, $e->getMessage());
548
  } else {
549
  throw new Exception($e->getMessage());
550
  }
551
  }
552
  }
553
- if($ftp) {
554
  $packager->writeToRemoteCache($cache, $ftpObj);
555
  @unlink($config->getFilename());
556
  }
557
  $out = array($command=>array('data'=>$deletedPackages, 'title'=>'Package deleted: '));
558
  $this->ui()->output($out);
559
-
560
  } catch (Exception $e) {
561
  return $this->doError($command, $e->getMessage());
562
  }
563
-
564
  }
565
-
566
  }
567
-
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
+ final class Mage_Connect_Command_Install extends Mage_Connect_Command
 
 
 
27
  {
 
28
  /**
29
  * Install action callback
30
+ *
31
+ * @throws Exception
32
  * @param string $command
33
  * @param array $options
34
  * @param array $params
35
+ * @param array $objects
36
+ * @return array|null
37
  */
38
  public function doInstall($command, $options, $params, $objects = array())
39
  {
41
 
42
  $installFileMode = $command === 'install-file';
43
 
44
+ /** @var $ftpObj Mage_Connect_Ftp */
 
 
 
 
45
  $ftpObj=null;
46
+ $ftp = empty($options['ftp']) ? false : $options['ftp'];
47
+ /** @var $packager Mage_Connect_Packager */
48
+ $packager = $this->getPackager();
49
+ /** @var $cache Mage_Connect_Singleconfig */
50
+ /** @var $config Mage_Connect_Config */
51
+ if ($ftp) {
52
+ list($cache, $config, $ftpObj) = $packager->getRemoteConf($ftp);
53
+ } else {
54
+ $cache = $this->getSconfig();
55
+ $config = $this->config();
56
+ }
57
 
58
  try {
 
59
  $forceMode = isset($options['force']);
60
  $upgradeAllMode = $command == 'upgrade-all';
61
  $upgradeMode = $command == 'upgrade' || $command == 'upgrade-all';
67
  $channelAuth = isset($options['auth'])?$options['auth']:array();
68
 
69
  $rest = $this->rest();
70
+ if (empty($config->magento_root)) {
 
 
 
 
 
 
 
71
  $config->magento_root=dirname(dirname($_SERVER['SCRIPT_FILENAME']));
72
  }
73
  chdir($config->magento_root);
76
  $dirTmp = DIRECTORY_SEPARATOR . Mage_Connect_Package_Reader::PATH_TO_TEMPORARY_DIRECTORY;
77
  $dirMedia = DIRECTORY_SEPARATOR . 'media';
78
  $isWritable = true;
79
+ if ($ftp) {
80
  $cwd=$ftpObj->getcwd();
81
  $ftpObj->mkdirRecursive($cwd . $dirCache,0777);
82
  $ftpObj->chdir($cwd);
99
  $isWritable = $isWritable && is_writable($config->magento_root . $dirMedia)
100
  && is_writable($config->magento_root . $dirCache)
101
  && is_writable($config->magento_root . $dirTmp);
102
+ if (!$isWritable) {
103
  $this->doError($command, $err);
104
  throw new Exception(
105
  'Your Magento folder does not have sufficient write permissions, which downloader requires.'
106
  );
107
  }
108
+ if (!empty($channelAuth)) {
109
  $rest->getLoader()->setCredentials($channelAuth['username'], $channelAuth['password']);
110
  }
111
 
112
+ if ($installFileMode) {
113
+ if (count($params) < 1) {
114
  throw new Exception("Argument should be: filename");
115
  }
116
  $filename = $params[0];
117
+ if (!@file_exists($filename)) {
118
  throw new Exception("File '{$filename}' not found");
119
  }
120
+ if (!@is_readable($filename)) {
121
  throw new Exception("File '{$filename}' is not readable");
122
  }
123
 
125
  $package->setConfig($config);
126
  $package->validate();
127
  $errors = $package->getErrors();
128
+ if (count($errors)) {
129
+ throw new Exception("Package file is invalid\n" . implode("\n", $errors));
130
  }
131
 
132
  $pChan = $package->getChannel();
133
  $pName = $package->getName();
134
  $pVer = $package->getVersion();
135
 
 
136
  if (!($cache->isChannelName($pChan) || $cache->isChannelAlias($pChan))) {
137
  throw new Exception("The '{$pChan}' channel is not installed. Please use the MAGE shell "
138
  . "script to install the '{$pChan}' channel.");
140
 
141
  $conflicts = $cache->hasConflicts($pChan, $pName, $pVer);
142
 
143
+ if (false !== $conflicts) {
144
  $conflicts = implode(", ",$conflicts);
145
+ if ($forceMode) {
146
+ $this->doError($command, "Package {$pChan}/{$pName} {$pVer} conflicts with: " . $conflicts);
147
  } else {
148
+ throw new Exception("Package {$pChan}/{$pName} {$pVer} conflicts with: " . $conflicts);
149
  }
150
  }
151
 
152
  $conflicts = $package->checkPhpDependencies();
153
+ if (true !== $conflicts) {
154
+ $conflicts = implode(",",$conflicts);
155
+ $err = "Package {$pChan}/{$pName} {$pVer} depends on PHP extensions: " . $conflicts;
156
+ if ($forceMode) {
157
  $this->doError($command, $err);
158
  } else {
159
  throw new Exception($err);
161
  }
162
 
163
  $conflicts = $package->checkPhpVersion();
164
+ if (true !== $conflicts) {
165
+ $err = "Package {$pChan}/{$pName} {$pVer}: " . $conflicts;
166
+ if ($forceMode) {
167
  $this->doError($command, $err);
168
  } else {
169
  throw new Exception($err);
170
  }
171
  }
172
 
173
+ if (!$noFilesInstall) {
174
+ if ($ftp) {
 
175
  $packager->processInstallPackageFtp($package, $filename, $config, $ftpObj);
176
  } else {
177
  $packager->processInstallPackage($package, $filename, $config);
183
  $installedDepsAssoc[] = array('channel'=>$pChan, 'name'=>$pName, 'version'=>$pVer);
184
  $installedDeps[] = array($pChan, $pName, $pVer);
185
 
 
186
  $title = isset($options['title']) ? $options['title'] : "Package installed: ";
187
  $out = array($command => array('data'=>$installedDeps, 'assoc'=>$installedDepsAssoc, 'title'=>$title));
188
 
189
+ if ($ftp) {
190
  $packager->writeToRemoteCache($cache, $ftpObj);
191
  @unlink($config->getFilename());
192
  }
195
  return $out[$command]['data'];
196
  }
197
 
198
+ if (!$upgradeAllMode) {
199
+ if (count($params) < 2) {
 
200
  throw new Exception("Argument should be: channelName packageName");
201
  }
202
  $channel = $params[0];
213
  /*
214
  * process 'failed' results
215
  */
216
+ if (count($packagesToInstall['failed'])) {
217
  $showError=!count($packagesToInstall['result']);
218
+ foreach ($packagesToInstall['failed'] as $failed) {
219
+ $msg="Package {$failed['channel']}/{$failed['name']} failed: " . $failed['reason'];
220
+ if ($showError) {
 
 
 
 
 
 
 
221
  $this->doError($command, $msg);
222
+ } else {
223
  $this->ui()->output($msg);
224
  }
225
  }
226
  }
227
  $packagesToInstall = $packagesToInstall['result'];
228
  } else {
229
+ if (empty($params[0])) {
230
  $channels = $cache->getChannelNames();
231
  } else {
232
  $channel = $params[0];
233
+ if (!$cache->isChannel($channel)) {
234
  throw new Exception("'{$channel}' is not existant channel name / valid uri");
235
  }
236
  $channels = $cache->chanName($channel);
237
  }
238
  $packagesToInstall = array();
239
  $neededToUpgrade = $packager->getUpgradesList($channels, $cache, $config, $rest);
240
+ foreach ($neededToUpgrade as $chan=>$packages) {
241
+ foreach ($packages as $name=>$data) {
242
  $versionTo = $data['to'];
243
  $tmp = $packager->getDependenciesList($chan, $name, $cache, $config, $versionTo, $versionTo,
244
  $withDepsMode, false, $rest
245
  );
246
+ if (count($tmp['result'])) {
247
  $packagesToInstall = array_merge($packagesToInstall, $tmp['result']);
248
  }
249
  }
255
  */
256
  $installedDeps = array();
257
  $installedDepsAssoc = array();
 
258
 
259
+ foreach ($packagesToInstall as $package) {
260
  try {
261
  $pName = $package['name'];
262
  $pChan = $package['channel'];
274
  continue;
275
  }
276
 
277
+ if ('incompartible' == $pInstallState) {
278
  $this->ui()->output(
279
  "Package incompartible with installed Magento: {$pChan}/{$pName} {$pVer}, skipping"
280
  );
283
 
284
  $conflicts = $cache->hasConflicts($pChan, $pName, $pVer);
285
 
286
+ if (false !== $conflicts) {
287
  $conflicts = implode(", ",$conflicts);
288
+ if ($forceMode) {
289
+ $this->doError($command, "Package {$pChan}/{$pName} {$pVer} conflicts with: " . $conflicts);
290
  } else {
291
+ throw new Exception("Package {$pChan}/{$pName} {$pVer} conflicts with: " . $conflicts);
292
  }
293
  }
294
 
296
  * Modifications
297
  */
298
  if (($upgradeMode || ($pInstallState == 'upgrade')) && !$ignoreModifiedMode) {
299
+ if ($ftp) {
300
  $modifications = $packager->getRemoteModifiedFiles($pChan, $pName, $cache, $config, $ftp);
301
  } else {
302
  $modifications = $packager->getLocalModifiedFiles($pChan, $pName, $cache, $config);
304
  if (count($modifications) > 0) {
305
  $this->ui()->output('Changed locally: ');
306
  foreach ($modifications as $row) {
307
+ if (!$ftp) {
308
+ $this->ui()->output($config->magento_root . DS . $row);
309
  } else {
310
  $this->ui()->output($row);
311
  }
312
  }
 
 
313
  }
314
  }
315
 
316
+ if ($ftp) {
317
  $cwd=$ftpObj->getcwd();
318
  $dir=$cwd . DIRECTORY_SEPARATOR .$config->downloader_path . DIRECTORY_SEPARATOR
319
  . Mage_Connect_Config::DEFAULT_CACHE_PATH . DIRECTORY_SEPARATOR . trim( $pChan, "\\/");
324
  @mkdir($dir, 0777, true);
325
  }
326
  $dir = $config->getChannelCacheDir($pChan);
327
+ $packageFileName = $pName . "-" . $pVer . ".tgz";
328
+ $file = $dir . DIRECTORY_SEPARATOR . $packageFileName;
329
+ if (!@file_exists($file)) {
330
  $this->ui()->output("Starting to download $packageFileName ...");
331
  $rest->downloadPackageFileOfRelease($pName, $pVer, $file);
332
  $this->ui()->output(sprintf("...done: %s bytes", number_format(filesize($file))));
354
  }
355
 
356
  $conflicts = $package->checkPhpDependencies();
357
+ if (true !== $conflicts) {
358
+ $conflicts = implode(",",$conflicts);
359
+ $err = "Package {$pChan}/{$pName} {$pVer} depends on PHP extensions: " . $conflicts;
360
+ if ($forceMode) {
361
  $this->doError($command, $err);
362
  } else {
363
  throw new Exception($err);
365
  }
366
 
367
  $conflicts = $package->checkPhpVersion();
368
+ if (true !== $conflicts) {
369
+ $err = "Package {$pChan}/{$pName} {$pVer}: " . $conflicts;
370
+ if ($forceMode) {
371
  $this->doError($command, $err);
372
  } else {
373
  throw new Exception($err);
374
  }
375
  }
376
 
377
+ if (!$noFilesInstall) {
 
 
 
378
  $this->ui()->output("Installing package {$pChan}/{$pName} {$pVer}");
379
+ if ($ftp) {
380
  $packager->processInstallPackageFtp($package, $file, $config, $ftpObj);
381
  } else {
382
  $packager->processInstallPackage($package, $file, $config);
393
  }
394
  }
395
 
 
 
396
  $title = isset($options['title']) ? $options['title'] : "Package installed: ";
397
  $out = array($command => array('data'=>$installedDeps, 'assoc'=>$installedDepsAssoc, 'title'=>$title));
398
 
399
+ if ($ftp) {
400
  $packager->writeToRemoteCache($cache, $ftpObj);
401
  @unlink($config->getFilename());
402
  }
403
 
404
  $this->ui()->output($out);
405
  return $out[$command]['data'];
 
406
  } catch (Exception $e) {
407
+ if ($ftp) {
408
  $packager->writeToRemoteCache($cache, $ftpObj);
409
  @unlink($config->getFilename());
410
  }
414
 
415
  /**
416
  * Upgrade action callback
417
+ *
418
  * @param string $command
419
  * @param array $options
420
  * @param array $params
421
+ * @return array|null
422
  */
423
  public function doUpgrade($command, $options, $params)
424
  {
428
 
429
  /**
430
  * Updgrade action callback
431
+ *
432
  * @param string $command
433
  * @param array $options
434
  * @param array $params
435
+ * @return array|null
436
  */
437
  public function doUpgradeAll($command, $options, $params)
438
  {
442
 
443
  /**
444
  * Uninstall package callback
445
+ *
446
  * @param string $command
447
  * @param array $options
448
  * @param array $params
449
+ * @return array|null
450
  */
451
  public function doUninstall($command, $options, $params)
452
  {
453
  $this->cleanupParams($params);
 
454
 
455
  try {
456
+ if (count($params) != 2) {
457
  throw new Exception("Argument count should be = 2");
458
  }
459
 
460
  $channel = $params[0];
461
  $package = $params[1];
462
+ /** @var $packager Mage_Connect_Packager */
463
  $packager = $this->getPackager();
464
+ $withDepsMode = !isset($options['nodeps'])? false : (boolean)$options['nodeps'];
465
  $forceMode = isset($options['force']);
466
 
467
  $ftp = empty($options['ftp']) ? false : $options['ftp'];
468
+ /** @var $cache Mage_Connect_Singleconfig */
469
+ /** @var $config Mage_Connect_Config */
470
+ /** @var $ftpObj Mage_Connect_Ftp */
471
+ if ($ftp) {
472
  list($cache, $config, $ftpObj) = $packager->getRemoteConf($ftp);
473
  } else {
474
  $cache = $this->getSconfig();
475
  $config = $this->config();
476
  }
477
 
 
478
  $channel = $cache->chanName($channel);
479
+ if (!$cache->hasPackage($channel, $package)) {
480
  throw new Exception("Package is not installed");
481
  }
482
 
483
  $deletedPackages = array();
484
  $list = $packager->getUninstallList($channel, $package, $cache, $config, $withDepsMode);
485
+ foreach ($list['list'] as $packageData) {
486
  try {
487
  $reqd = $cache->requiredByOtherPackages(
488
  $packageData['channel'],
489
  $packageData['name'],
490
  $list['list']
491
  );
492
+ if (count($reqd)) {
493
  $errMessage = "{$packageData['channel']}/{$packageData['name']} "
494
  . "{$packageData['version']} is required by: ";
495
  $t = array();
496
+ foreach ($reqd as $r) {
497
+ $t[] = $r['channel'] . "/" . $r['name'] . " " . $r['version'];
498
  }
499
  $errMessage .= implode(", ", $t);
500
+ if ($forceMode) {
501
+ $this->ui()->output("Warning: " . $errMessage);
502
  } else {
503
  throw new Exception($errMessage);
504
  }
505
  }
506
  } catch(Exception $e) {
507
+ if ($forceMode) {
508
  $this->doError($command, $e->getMessage());
509
  } else {
510
  throw new Exception($e->getMessage());
511
  }
512
  }
513
  }
514
+ foreach ($list['list'] as $packageData) {
515
  try {
516
  list($chan, $pack) = array($packageData['channel'], $packageData['name']);
517
  $packageName = $packageData['channel'] . "/" . $packageData['name'];
518
  $this->ui()->output("Starting to uninstall $packageName ");
519
+ if ($ftp) {
520
  $packager->processUninstallPackageFtp($chan, $pack, $cache, $ftpObj);
521
  } else {
522
  $packager->processUninstallPackage($chan, $pack, $cache, $config);
525
  $deletedPackages[] = array($chan, $pack);
526
  $this->ui()->output("Package {$packageName} uninstalled");
527
  } catch(Exception $e) {
528
+ if ($forceMode) {
529
  $this->doError($command, $e->getMessage());
530
  } else {
531
  throw new Exception($e->getMessage());
532
  }
533
  }
534
  }
535
+ if ($ftp) {
536
  $packager->writeToRemoteCache($cache, $ftpObj);
537
  @unlink($config->getFilename());
538
  }
539
  $out = array($command=>array('data'=>$deletedPackages, 'title'=>'Package deleted: '));
540
  $this->ui()->output($out);
541
+ return $out[$command]['data'];
542
  } catch (Exception $e) {
543
  return $this->doError($command, $e->getMessage());
544
  }
 
545
  }
 
546
  }
 
downloader/lib/Mage/Connect/Command/Install_Header.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/Connect/Command/Package.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/Connect/Command/Package_Header.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/Connect/Command/Registry.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/Connect/Command/Registry_Header.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/Connect/Command/Remote.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/Connect/Command/Remote_Header.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/Connect/Config.php CHANGED
@@ -20,9 +20,30 @@
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
  class Mage_Connect_Config implements Iterator
27
  {
28
  /**
@@ -53,11 +74,28 @@ class Mage_Connect_Config implements Iterator
53
  */
54
  protected $_configError = '';
55
 
 
 
 
56
  const HEADER = "::ConnectConfig::v::1.0::";
 
 
 
 
57
  const DEFAULT_DOWNLOADER_PATH = "downloader";
58
  const DEFAULT_CACHE_PATH = ".cache";
59
 
 
 
 
 
60
  protected $defaultProperties = array();
 
 
 
 
 
 
61
  protected $properties = array();
62
 
63
  /**
@@ -71,6 +109,11 @@ class Mage_Connect_Config implements Iterator
71
  $this->load();
72
  }
73
 
 
 
 
 
 
74
  protected function initProperties()
75
  {
76
  $this->defaultProperties = array (
@@ -162,22 +205,43 @@ class Mage_Connect_Config implements Iterator
162
  $this->properties = $this->defaultProperties;
163
  }
164
 
 
 
 
 
 
165
  public function getDownloaderPath()
166
  {
167
  return $this->magento_root . DIRECTORY_SEPARATOR . $this->downloader_path;
168
  }
169
 
 
 
 
 
 
170
  public function getPackagesCacheDir()
171
  {
172
  return $this->getDownloaderPath() . DIRECTORY_SEPARATOR . self::DEFAULT_CACHE_PATH;
173
  }
174
 
 
 
 
 
 
 
175
  public function getChannelCacheDir($channel)
176
  {
177
  $channel = trim( $channel, "\\/");
178
  return $this->getPackagesCacheDir(). DIRECTORY_SEPARATOR . $channel;
179
  }
180
 
 
 
 
 
 
181
  public function getFilename()
182
  {
183
  return $this->_configFile;
@@ -211,7 +275,7 @@ class Mage_Connect_Config implements Iterator
211
 
212
  clearstatcache();
213
  $size = filesize($this->_configFile);
214
- if(!$size) {
215
  $this->_configError = "Wrong config file size {$this->_configFile} please save Settings again";
216
  return false;
217
  }
@@ -219,7 +283,7 @@ class Mage_Connect_Config implements Iterator
219
  $headerLen = strlen(self::HEADER);
220
  try {
221
  $contents = fread($f, $headerLen);
222
- if(self::HEADER != $contents) {
223
  $this->_configError = "Wrong configuration file {$this->_configFile} please save Settings again";
224
  return false;
225
  }
@@ -232,7 +296,7 @@ class Mage_Connect_Config implements Iterator
232
  return false;
233
  }
234
  $data = @unserialize($contents);
235
- if($data === false) {
236
  $this->_configError = "Wrong configuration file {$this->_configFile} please save Settings again";
237
  return false;
238
  }
@@ -241,6 +305,7 @@ class Mage_Connect_Config implements Iterator
241
  }
242
  @fclose($f);
243
  $this->_configLoaded=true;
 
244
  }
245
 
246
  /**
@@ -301,83 +366,158 @@ class Mage_Connect_Config implements Iterator
301
  return $result;
302
  }
303
 
 
 
 
 
 
 
 
304
  public function validate($key, $val)
305
  {
306
  $rules = $this->extractField($key, 'rules');
307
- if(null === $rules) {
308
  return true;
309
- } elseif( is_array($rules) ) {
310
  return in_array($val, $rules);
311
  }
312
  return false;
313
  }
314
 
 
 
 
 
 
 
315
  public function possible($key)
316
  {
317
  $data = $this->getKey($key);
318
- if(! $data) {
319
  return null;
320
  }
321
- if('set' == $data['type']) {
322
  return implode("|", $data['rules']);
323
  }
324
- if(!empty($data['possible'])) {
325
  return $data['possible'];
326
  }
327
- return "<".$data['type'].">";
328
  }
329
 
 
 
 
 
 
 
330
  public function type($key)
331
  {
332
  return $this->extractField($key, 'type');
333
  }
334
 
 
 
 
 
 
 
335
  public function doc($key)
336
  {
337
  return $this->extractField($key, 'doc');
338
  }
339
 
 
 
 
 
 
 
 
340
  public function extractField($key, $field)
341
  {
342
- if(!isset($this->properties[$key][$field])) {
343
  return null;
344
  }
345
  return $this->properties[$key][$field];
346
  }
347
 
 
 
 
 
 
 
348
  public function hasKey($fld)
349
  {
350
  return isset($this->properties[$fld]);
351
  }
352
 
 
 
 
 
 
 
353
  public function getKey($fld)
354
  {
355
- if($this->hasKey($fld)) {
356
  return $this->properties[$fld];
357
  }
358
  return null;
359
  }
360
 
 
 
 
 
 
361
  public function rewind() {
362
  reset($this->properties);
363
  }
364
 
 
 
 
 
 
365
  public function valid() {
366
  return current($this->properties) !== false;
367
  }
368
 
 
 
 
 
 
369
  public function key() {
370
  return key($this->properties);
371
  }
372
 
 
 
 
 
 
373
  public function current() {
374
  return current($this->properties);
375
  }
376
 
 
 
 
 
 
377
  public function next() {
378
  next($this->properties);
379
  }
380
 
 
 
 
 
 
 
381
  public function __get($var)
382
  {
383
  if (isset($this->properties[$var]['value'])) {
@@ -386,6 +526,13 @@ class Mage_Connect_Config implements Iterator
386
  return null;
387
  }
388
 
 
 
 
 
 
 
 
389
  public function __set($var, $value)
390
  {
391
  if (is_string($value)) {
@@ -395,17 +542,23 @@ class Mage_Connect_Config implements Iterator
395
  if ($value === null) {
396
  $value = '';
397
  }
398
- if($this->properties[$var]['value'] !== $value) {
399
  $this->properties[$var]['value'] = $value;
400
  $this->store();
401
  }
402
  }
403
  }
404
 
 
 
 
 
 
 
405
  public function toArray($withRules = false)
406
  {
407
  $out = array();
408
- foreach($this as $k=>$v) {
409
  $out[$k] = $withRules ? $v : $v['value'];
410
  }
411
  return $out;
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
+
27
+ /**
28
+ * Magento Connect Config
29
+ *
30
+ * @property string php_ini
31
+ * @property string protocol
32
+ * @property string preferred_state
33
+ * @property string use_custom_permissions_mode
34
+ * @property string global_dir_mode
35
+ * @property string global_file_mode
36
+ * @property string downloader_path
37
+ * @property string magento_root
38
+ * @property string root_channel_uri
39
+ * @property string root_channel
40
+ * @property string remote_config
41
+ * @property string sync_pear
42
+ *
43
+ * @category Mage
44
+ * @package Mage_Connect
45
+ * @author Magento Core Team <core@magentocommerce.com>
46
+ */
47
  class Mage_Connect_Config implements Iterator
48
  {
49
  /**
74
  */
75
  protected $_configError = '';
76
 
77
+ /**
78
+ * Header string
79
+ */
80
  const HEADER = "::ConnectConfig::v::1.0::";
81
+
82
+ /**
83
+ * Default paths
84
+ */
85
  const DEFAULT_DOWNLOADER_PATH = "downloader";
86
  const DEFAULT_CACHE_PATH = ".cache";
87
 
88
+ /**
89
+ * Array of default properties
90
+ * @var array
91
+ */
92
  protected $defaultProperties = array();
93
+
94
+ /**
95
+ * Array of properties
96
+ *
97
+ * @var array
98
+ */
99
  protected $properties = array();
100
 
101
  /**
109
  $this->load();
110
  }
111
 
112
+ /**
113
+ * Initialise Properties and Default Properties
114
+ *
115
+ * @return void
116
+ */
117
  protected function initProperties()
118
  {
119
  $this->defaultProperties = array (
205
  $this->properties = $this->defaultProperties;
206
  }
207
 
208
+ /**
209
+ * Retrieve Downloader Path
210
+ *
211
+ * @return string
212
+ */
213
  public function getDownloaderPath()
214
  {
215
  return $this->magento_root . DIRECTORY_SEPARATOR . $this->downloader_path;
216
  }
217
 
218
+ /**
219
+ * Retrieve Packages Cache Directory
220
+ *
221
+ * @return string
222
+ */
223
  public function getPackagesCacheDir()
224
  {
225
  return $this->getDownloaderPath() . DIRECTORY_SEPARATOR . self::DEFAULT_CACHE_PATH;
226
  }
227
 
228
+ /**
229
+ * Retrieve Channel Cache Directory
230
+ *
231
+ * @param string $channel
232
+ * @return string
233
+ */
234
  public function getChannelCacheDir($channel)
235
  {
236
  $channel = trim( $channel, "\\/");
237
  return $this->getPackagesCacheDir(). DIRECTORY_SEPARATOR . $channel;
238
  }
239
 
240
+ /**
241
+ * Get Config file name
242
+ *
243
+ * @return string
244
+ */
245
  public function getFilename()
246
  {
247
  return $this->_configFile;
275
 
276
  clearstatcache();
277
  $size = filesize($this->_configFile);
278
+ if (!$size) {
279
  $this->_configError = "Wrong config file size {$this->_configFile} please save Settings again";
280
  return false;
281
  }
283
  $headerLen = strlen(self::HEADER);
284
  try {
285
  $contents = fread($f, $headerLen);
286
+ if (self::HEADER != $contents) {
287
  $this->_configError = "Wrong configuration file {$this->_configFile} please save Settings again";
288
  return false;
289
  }
296
  return false;
297
  }
298
  $data = @unserialize($contents);
299
+ if ($data === false) {
300
  $this->_configError = "Wrong configuration file {$this->_configFile} please save Settings again";
301
  return false;
302
  }
305
  }
306
  @fclose($f);
307
  $this->_configLoaded=true;
308
+ return true;
309
  }
310
 
311
  /**
366
  return $result;
367
  }
368
 
369
+ /**
370
+ * Validate value for configuration key
371
+ *
372
+ * @param string $key
373
+ * @param mixed $val
374
+ * @return bool
375
+ */
376
  public function validate($key, $val)
377
  {
378
  $rules = $this->extractField($key, 'rules');
379
+ if (null === $rules) {
380
  return true;
381
+ } elseif ( is_array($rules) ) {
382
  return in_array($val, $rules);
383
  }
384
  return false;
385
  }
386
 
387
+ /**
388
+ * Get possible values for configuration key
389
+ *
390
+ * @param string $key
391
+ * @return null|string
392
+ */
393
  public function possible($key)
394
  {
395
  $data = $this->getKey($key);
396
+ if (! $data) {
397
  return null;
398
  }
399
+ if ('set' == $data['type']) {
400
  return implode("|", $data['rules']);
401
  }
402
+ if (!empty($data['possible'])) {
403
  return $data['possible'];
404
  }
405
+ return "<" . $data['type'] . ">";
406
  }
407
 
408
+ /**
409
+ * Get type of key
410
+ *
411
+ * @param string $key
412
+ * @return mixed|null
413
+ */
414
  public function type($key)
415
  {
416
  return $this->extractField($key, 'type');
417
  }
418
 
419
+ /**
420
+ * Get documentation information
421
+ *
422
+ * @param string $key
423
+ * @return mixed|null
424
+ */
425
  public function doc($key)
426
  {
427
  return $this->extractField($key, 'doc');
428
  }
429
 
430
+ /**
431
+ * Get property of key
432
+ *
433
+ * @param $key
434
+ * @param $field
435
+ * @return mixed|null
436
+ */
437
  public function extractField($key, $field)
438
  {
439
+ if (!isset($this->properties[$key][$field])) {
440
  return null;
441
  }
442
  return $this->properties[$key][$field];
443
  }
444
 
445
+ /**
446
+ * Check Key exists in properties array
447
+ *
448
+ * @param string $fld
449
+ * @return bool
450
+ */
451
  public function hasKey($fld)
452
  {
453
  return isset($this->properties[$fld]);
454
  }
455
 
456
+ /**
457
+ * Get all Key properties
458
+ *
459
+ * @param $fld
460
+ * @return null
461
+ */
462
  public function getKey($fld)
463
  {
464
+ if ($this->hasKey($fld)) {
465
  return $this->properties[$fld];
466
  }
467
  return null;
468
  }
469
 
470
+ /**
471
+ * Set the internal pointer of the Properties array to its first element
472
+ *
473
+ * @return void
474
+ */
475
  public function rewind() {
476
  reset($this->properties);
477
  }
478
 
479
+ /**
480
+ * Validate current property
481
+ *
482
+ * @return bool
483
+ */
484
  public function valid() {
485
  return current($this->properties) !== false;
486
  }
487
 
488
+ /**
489
+ * Get Key of current property
490
+ *
491
+ * @return mixed
492
+ */
493
  public function key() {
494
  return key($this->properties);
495
  }
496
 
497
+ /**
498
+ * Get current Property
499
+ *
500
+ * @return mixed
501
+ */
502
  public function current() {
503
  return current($this->properties);
504
  }
505
 
506
+ /**
507
+ * Advance the internal array pointer of the Properties array
508
+ *
509
+ * @return void
510
+ */
511
  public function next() {
512
  next($this->properties);
513
  }
514
 
515
+ /**
516
+ * Retrieve value of property
517
+ *
518
+ * @param string $var
519
+ * @return null
520
+ */
521
  public function __get($var)
522
  {
523
  if (isset($this->properties[$var]['value'])) {
526
  return null;
527
  }
528
 
529
+ /**
530
+ * Set value of property
531
+ *
532
+ * @param string $var
533
+ * @param mixed $value
534
+ * @return void
535
+ */
536
  public function __set($var, $value)
537
  {
538
  if (is_string($value)) {
542
  if ($value === null) {
543
  $value = '';
544
  }
545
+ if ($this->properties[$var]['value'] !== $value) {
546
  $this->properties[$var]['value'] = $value;
547
  $this->store();
548
  }
549
  }
550
  }
551
 
552
+ /**
553
+ * Prepare Array of class properties
554
+ *
555
+ * @param bool $withRules
556
+ * @return array
557
+ */
558
  public function toArray($withRules = false)
559
  {
560
  $out = array();
561
+ foreach ($this as $k=>$v) {
562
  $out[$k] = $withRules ? $v : $v['value'];
563
  }
564
  return $out;
downloader/lib/Mage/Connect/Converter.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/Connect/Frontend.php CHANGED
@@ -20,50 +20,53 @@
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
-
27
  class Mage_Connect_Frontend
28
  {
29
-
30
  /**
31
  * Silent flag. If set no output is produced to view.
32
  * Should be used in derived classes.
33
- * @var bool
 
34
  */
35
  protected $_silent = false;
36
 
37
  /**
38
  * Capture mode. If set command output should be collected
39
  * by derived class impplementation
40
- * @var bool
 
41
  */
42
  protected $_capture = false;
43
 
44
-
45
  /**
46
  * push/pop variable for capture
 
47
  * @var array
48
  */
49
  protected $_captureSaved = array();
50
 
51
  /**
52
  * push/pop variable for silent
 
53
  * @var array
54
  */
55
  protected $_silentSaved = array();
56
 
57
  /**
58
  * Errors list
 
59
  * @var array
60
  */
61
  protected $_errors = array();
62
 
63
  /**
64
  * Add error to errors list
 
65
  * @param mixed $data
66
- * @return void
67
  */
68
  public function addError($data)
69
  {
@@ -72,7 +75,8 @@ class Mage_Connect_Frontend
72
 
73
  /**
74
  * Get errors, clear errors list with first param
75
- * @param bool $clear
 
76
  * @return array
77
  */
78
  public function getErrors($clear = true)
@@ -87,7 +91,8 @@ class Mage_Connect_Frontend
87
 
88
  /**
89
  * Clear errors array
90
- * @return void
 
91
  */
92
  public function clearErrors()
93
  {
@@ -96,7 +101,8 @@ class Mage_Connect_Frontend
96
 
97
  /**
98
  * Are there any errros?
99
- * @return bool
 
100
  */
101
  public function hasErrors()
102
  {
@@ -106,8 +112,8 @@ class Mage_Connect_Frontend
106
  /**
107
  * Error processing
108
  * @param string $command
109
- * @param stting $message
110
- * @return void
111
  */
112
  public function doError($command, $message)
113
  {
@@ -116,6 +122,7 @@ class Mage_Connect_Frontend
116
 
117
  /**
118
  * Save capture state
 
119
  * @return Mage_Connect_Frontend
120
  */
121
  public function pushCapture()
@@ -126,6 +133,7 @@ class Mage_Connect_Frontend
126
 
127
  /**
128
  * Restore capture state
 
129
  * @return Mage_Connect_Frontend
130
  */
131
  public function popCapture()
@@ -136,7 +144,8 @@ class Mage_Connect_Frontend
136
 
137
  /**
138
  * Set capture mode
139
- * @param bool $arg true by default
 
140
  * @return Mage_Connect_Frontend
141
  */
142
  public function setCapture($arg = true)
@@ -147,7 +156,8 @@ class Mage_Connect_Frontend
147
 
148
  /**
149
  * Getter for capture mode
150
- * @return bool
 
151
  */
152
  public function isCapture()
153
  {
@@ -156,6 +166,7 @@ class Mage_Connect_Frontend
156
 
157
  /**
158
  * Log stub
 
159
  * @param $msg
160
  * @return
161
  */
@@ -166,8 +177,9 @@ class Mage_Connect_Frontend
166
 
167
  /**
168
  * Ouptut method
 
169
  * @param array $data
170
- * @return void
171
  */
172
  public function output($data)
173
  {
@@ -189,7 +201,8 @@ class Mage_Connect_Frontend
189
  /**
190
  * Get output if capture mode set
191
  * Clear prevoius if needed
192
- * @param bool $clearPrevious
 
193
  * @return mixed
194
  */
195
  public function getOutput($clearPrevious = true)
@@ -197,9 +210,9 @@ class Mage_Connect_Frontend
197
 
198
  }
199
 
200
-
201
  /**
202
  * Save silent mode
 
203
  * @return Mage_Connect_Frontend
204
  */
205
  public function pushSilent()
@@ -210,6 +223,7 @@ class Mage_Connect_Frontend
210
 
211
  /**
212
  * Restore silent mode
 
213
  * @return Mage_Connect_Frontend
214
  */
215
  public function popSilent()
@@ -220,22 +234,24 @@ class Mage_Connect_Frontend
220
 
221
  /**
222
  * Set silent mode
223
- * @param bool $value
 
224
  * @return Mage_Connect_Frontend
225
  */
226
  public function setSilent($value = true)
227
  {
228
- $this->_silent = (bool) $value;
229
  return $this;
230
  }
231
 
232
  /**
233
  * Is silent mode?
234
- * @return bool
 
235
  */
236
  public function isSilent()
237
  {
238
- return (bool) $this->_silent;
239
  }
240
 
241
  /**
@@ -245,7 +261,7 @@ class Mage_Connect_Frontend
245
  */
246
  public function confirm($string)
247
  {
248
-
249
  }
250
  }
251
 
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
  class Mage_Connect_Frontend
27
  {
 
28
  /**
29
  * Silent flag. If set no output is produced to view.
30
  * Should be used in derived classes.
31
+ *
32
+ * @var boolean
33
  */
34
  protected $_silent = false;
35
 
36
  /**
37
  * Capture mode. If set command output should be collected
38
  * by derived class impplementation
39
+ *
40
+ * @var boolean
41
  */
42
  protected $_capture = false;
43
 
 
44
  /**
45
  * push/pop variable for capture
46
+ *
47
  * @var array
48
  */
49
  protected $_captureSaved = array();
50
 
51
  /**
52
  * push/pop variable for silent
53
+ *
54
  * @var array
55
  */
56
  protected $_silentSaved = array();
57
 
58
  /**
59
  * Errors list
60
+ *
61
  * @var array
62
  */
63
  protected $_errors = array();
64
 
65
  /**
66
  * Add error to errors list
67
+ *
68
  * @param mixed $data
69
+ * @return null
70
  */
71
  public function addError($data)
72
  {
75
 
76
  /**
77
  * Get errors, clear errors list with first param
78
+ *
79
+ * @param boolean $clear
80
  * @return array
81
  */
82
  public function getErrors($clear = true)
91
 
92
  /**
93
  * Clear errors array
94
+ *
95
+ * @return null
96
  */
97
  public function clearErrors()
98
  {
101
 
102
  /**
103
  * Are there any errros?
104
+ *
105
+ * @return boolean
106
  */
107
  public function hasErrors()
108
  {
112
  /**
113
  * Error processing
114
  * @param string $command
115
+ * @param string $message
116
+ * @return null
117
  */
118
  public function doError($command, $message)
119
  {
122
 
123
  /**
124
  * Save capture state
125
+ *
126
  * @return Mage_Connect_Frontend
127
  */
128
  public function pushCapture()
133
 
134
  /**
135
  * Restore capture state
136
+ *
137
  * @return Mage_Connect_Frontend
138
  */
139
  public function popCapture()
144
 
145
  /**
146
  * Set capture mode
147
+ *
148
+ * @param boolean $arg true by default
149
  * @return Mage_Connect_Frontend
150
  */
151
  public function setCapture($arg = true)
156
 
157
  /**
158
  * Getter for capture mode
159
+ *
160
+ * @return boolean
161
  */
162
  public function isCapture()
163
  {
166
 
167
  /**
168
  * Log stub
169
+ *
170
  * @param $msg
171
  * @return
172
  */
177
 
178
  /**
179
  * Ouptut method
180
+ *
181
  * @param array $data
182
+ * @return null
183
  */
184
  public function output($data)
185
  {
201
  /**
202
  * Get output if capture mode set
203
  * Clear prevoius if needed
204
+ *
205
+ * @param boolean $clearPrevious
206
  * @return mixed
207
  */
208
  public function getOutput($clearPrevious = true)
210
 
211
  }
212
 
 
213
  /**
214
  * Save silent mode
215
+ *
216
  * @return Mage_Connect_Frontend
217
  */
218
  public function pushSilent()
223
 
224
  /**
225
  * Restore silent mode
226
+ *
227
  * @return Mage_Connect_Frontend
228
  */
229
  public function popSilent()
234
 
235
  /**
236
  * Set silent mode
237
+ *
238
+ * @param boolean $value
239
  * @return Mage_Connect_Frontend
240
  */
241
  public function setSilent($value = true)
242
  {
243
+ $this->_silent = (boolean) $value;
244
  return $this;
245
  }
246
 
247
  /**
248
  * Is silent mode?
249
+ *
250
+ * @return boolean
251
  */
252
  public function isSilent()
253
  {
254
+ return (boolean) $this->_silent;
255
  }
256
 
257
  /**
261
  */
262
  public function confirm($string)
263
  {
264
+
265
  }
266
  }
267
 
downloader/lib/Mage/Connect/Frontend/CLI.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/Connect/Ftp.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
 
@@ -33,22 +33,18 @@
33
  */
34
  class Mage_Connect_Ftp
35
  {
36
-
37
  /**
38
  * Connection object
 
39
  * @var resource
40
  */
41
  protected $_conn = false;
42
 
43
- public function __construct()
44
- {
45
-
46
- }
47
-
48
  /**
49
  * Check connected, throw exception if not
 
50
  * @throws Exception
51
- * @return void
52
  */
53
  protected function checkConnected()
54
  {
@@ -59,8 +55,9 @@ class Mage_Connect_Ftp
59
 
60
  /**
61
  * ftp_mkdir wrapper
62
- * @param stin$name
63
- * @return unknown_type
 
64
  */
65
  public function mdkir($name)
66
  {
@@ -68,10 +65,9 @@ class Mage_Connect_Ftp
68
  return @ftp_mkdir($this->_conn, $name);
69
  }
70
 
71
-
72
-
73
  /**
74
  * Make dir recursive
 
75
  * @param string $path
76
  * @param int $mode
77
  */
@@ -96,13 +92,13 @@ class Mage_Connect_Ftp
96
  return $ret;
97
  }
98
 
99
-
100
  /**
101
  * Try to login to server
 
102
  * @param string $login
103
  * @param string $password
104
  * @throws Exception on invalid login credentials
105
- * @return bool
106
  */
107
  public function login($login = "anonymous", $password = "test@gmail.com")
108
  {
@@ -116,6 +112,7 @@ class Mage_Connect_Ftp
116
 
117
  /**
118
  * Validate connection string
 
119
  * @param string $string
120
  * @throws Exception
121
  * @return string
@@ -139,10 +136,10 @@ class Mage_Connect_Ftp
139
  * Connect to server using connect string
140
  * Connection string: ftp://user:pass@server:port/path
141
  * user,pass,port,path are optional parts
142
- * @param string $string
143
  *
144
- * @param $timeout
145
- * @return unknown_type
 
146
  */
147
  public function connect($string, $timeout = 90)
148
  {
@@ -169,13 +166,13 @@ class Mage_Connect_Ftp
169
 
170
  /**
171
  * ftp_fput wrapper
 
172
  * @param string $remoteFile
173
  * @param resource $handle
174
  * @param int $mode FTP_BINARY | FTP_ASCII
175
  * @param int $startPos
176
- * @return bool
177
  */
178
-
179
  public function fput($remoteFile, $handle, $mode = FTP_BINARY, $startPos = 0)
180
  {
181
  $this->checkConnected();
@@ -184,11 +181,12 @@ class Mage_Connect_Ftp
184
 
185
  /**
186
  * ftp_put wrapper
 
187
  * @param string $remoteFile
188
  * @param string $localFile
189
  * @param int $mode FTP_BINARY | FTP_ASCII
190
  * @param int $startPos
191
- * @return bool
192
  */
193
  public function put($remoteFile, $localFile, $mode = FTP_BINARY, $startPos = 0)
194
  {
@@ -196,10 +194,10 @@ class Mage_Connect_Ftp
196
  return @ftp_put($this->_conn, $remoteFile, $localFile, $mode, $startPos);
197
  }
198
 
199
-
200
  /**
201
  * Get current working directory
202
- * @return mixed
 
203
  */
204
  public function getcwd()
205
  {
@@ -220,8 +218,9 @@ class Mage_Connect_Ftp
220
 
221
  /**
222
  * ftp_raw wrapper
 
223
  * @param string $cmd
224
- * @return mixed
225
  */
226
  public function raw($cmd)
227
  {
@@ -229,18 +228,16 @@ class Mage_Connect_Ftp
229
  return @ftp_raw($this->_conn, $cmd);
230
  }
231
 
232
-
233
  /**
234
- * Upload local file to remote
235
- *
236
  * Can be used for relative and absoulte remote paths
237
  * Relative: use chdir before calling this
238
  *
239
- * @param srting $remote
240
  * @param string $local
241
  * @param int $dirMode
242
  * @param int $fileMode
243
- * @return bool
244
  */
245
  public function upload($remote, $local, $dirMode = 0777, $fileMode=0)
246
  {
@@ -282,15 +279,16 @@ class Mage_Connect_Ftp
282
  if($fileMode){
283
  $res=$this->chmod($fileMode, $remote);
284
  }
285
- return (bool)$res;
286
  }
287
 
288
  /**
289
  * Download remote file to local machine
 
290
  * @param string $remote
291
  * @param string $local
292
  * @param int $ftpMode FTP_BINARY|FTP_ASCII
293
- * @return bool
294
  */
295
  public function download($remote, $local, $ftpMode = FTP_BINARY)
296
  {
@@ -298,21 +296,22 @@ class Mage_Connect_Ftp
298
  return $this->get($local, $remote, $ftpMode);
299
  }
300
 
301
-
302
  /**
303
  * ftp_pasv wrapper
304
- * @param bool $pasv
305
- * @return bool
 
306
  */
307
  public function pasv($pasv)
308
  {
309
  $this->checkConnected();
310
- return @ftp_pasv($this->_conn, (bool) $pasv);
311
  }
312
 
313
  /**
314
  * Close FTP connection
315
- * @return void
 
316
  */
317
  public function close()
318
  {
@@ -323,9 +322,10 @@ class Mage_Connect_Ftp
323
 
324
  /**
325
  * ftp_chmod wrapper
 
326
  * @param $mode
327
  * @param $remoteFile
328
- * @return bool
329
  */
330
  public function chmod($mode, $remoteFile)
331
  {
@@ -335,8 +335,9 @@ class Mage_Connect_Ftp
335
 
336
  /**
337
  * ftp_chdir wrapper
 
338
  * @param string $dir
339
- * @return bool
340
  */
341
  public function chdir($dir)
342
  {
@@ -346,7 +347,8 @@ class Mage_Connect_Ftp
346
 
347
  /**
348
  * ftp_cdup wrapper
349
- * @return bool
 
350
  */
351
  public function cdup()
352
  {
@@ -356,11 +358,12 @@ class Mage_Connect_Ftp
356
 
357
  /**
358
  * ftp_get wrapper
 
359
  * @param string $localFile
360
  * @param string $remoteFile
361
  * @param int $fileMode FTP_BINARY | FTP_ASCII
362
  * @param int $resumeOffset
363
- * @return bool
364
  */
365
  public function get($localFile, $remoteFile, $fileMode = FTP_BINARY, $resumeOffset = 0)
366
  {
@@ -371,8 +374,9 @@ class Mage_Connect_Ftp
371
 
372
  /**
373
  * ftp_nlist wrapper
 
374
  * @param string $dir
375
- * @return bool
376
  */
377
  public function nlist($dir = "/")
378
  {
@@ -383,9 +387,10 @@ class Mage_Connect_Ftp
383
 
384
  /**
385
  * ftp_rawlist wrapper
 
386
  * @param string $dir
387
- * @param bool $recursive
388
- * @return mixed
389
  */
390
  public function rawlist( $dir = "/", $recursive = false )
391
  {
@@ -394,9 +399,9 @@ class Mage_Connect_Ftp
394
  return @ftp_rawlist($this->_conn, $dir, $recursive);
395
  }
396
 
397
-
398
  /**
399
  * Convert byte count to float KB/MB format
 
400
  * @param int $bytes
401
  * @return string
402
  */
@@ -409,6 +414,7 @@ class Mage_Connect_Ftp
409
 
410
  /**
411
  * Chmod string "-rwxrwxrwx" to "777" converter
 
412
  * @param string $chmod
413
  * @return string
414
  */
@@ -424,8 +430,8 @@ class Mage_Connect_Ftp
424
  * Checks file exists
425
  *
426
  * @param string $path
427
- * @param bool $excludeIfIsDir
428
- * @return bool
429
  */
430
  public function fileExists($path, $excludeIfIsDir = true)
431
  {
@@ -448,8 +454,9 @@ class Mage_Connect_Ftp
448
 
449
  /**
450
  * Get directory contents in PHP array
 
451
  * @param string $dir
452
- * @param bool $recursive
453
  * @return array
454
  */
455
  public function ls($dir = "/", $recursive = false)
@@ -487,6 +494,7 @@ class Mage_Connect_Ftp
487
 
488
  /**
489
  * Correct file path
 
490
  * @param $str
491
  * @return string
492
  */
@@ -499,8 +507,9 @@ class Mage_Connect_Ftp
499
 
500
  /**
501
  * Delete file
 
502
  * @param string $file
503
- * @return bool
504
  */
505
  public function delete($file)
506
  {
@@ -511,8 +520,9 @@ class Mage_Connect_Ftp
511
 
512
  /**
513
  * Remove directory
 
514
  * @param string $dir
515
- * @return bool
516
  */
517
  public function rmdir($dir)
518
  {
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
 
33
  */
34
  class Mage_Connect_Ftp
35
  {
 
36
  /**
37
  * Connection object
38
+ *
39
  * @var resource
40
  */
41
  protected $_conn = false;
42
 
 
 
 
 
 
43
  /**
44
  * Check connected, throw exception if not
45
+ *
46
  * @throws Exception
47
+ * @return null
48
  */
49
  protected function checkConnected()
50
  {
55
 
56
  /**
57
  * ftp_mkdir wrapper
58
+ *
59
+ * @param string $name
60
+ * @return string
61
  */
62
  public function mdkir($name)
63
  {
65
  return @ftp_mkdir($this->_conn, $name);
66
  }
67
 
 
 
68
  /**
69
  * Make dir recursive
70
+ *
71
  * @param string $path
72
  * @param int $mode
73
  */
92
  return $ret;
93
  }
94
 
 
95
  /**
96
  * Try to login to server
97
+ *
98
  * @param string $login
99
  * @param string $password
100
  * @throws Exception on invalid login credentials
101
+ * @return boolean
102
  */
103
  public function login($login = "anonymous", $password = "test@gmail.com")
104
  {
112
 
113
  /**
114
  * Validate connection string
115
+ *
116
  * @param string $string
117
  * @throws Exception
118
  * @return string
136
  * Connect to server using connect string
137
  * Connection string: ftp://user:pass@server:port/path
138
  * user,pass,port,path are optional parts
 
139
  *
140
+ * @param string $string
141
+ * @param int $timeout
142
+ * @return null
143
  */
144
  public function connect($string, $timeout = 90)
145
  {
166
 
167
  /**
168
  * ftp_fput wrapper
169
+ *
170
  * @param string $remoteFile
171
  * @param resource $handle
172
  * @param int $mode FTP_BINARY | FTP_ASCII
173
  * @param int $startPos
174
+ * @return boolean
175
  */
 
176
  public function fput($remoteFile, $handle, $mode = FTP_BINARY, $startPos = 0)
177
  {
178
  $this->checkConnected();
181
 
182
  /**
183
  * ftp_put wrapper
184
+ *
185
  * @param string $remoteFile
186
  * @param string $localFile
187
  * @param int $mode FTP_BINARY | FTP_ASCII
188
  * @param int $startPos
189
+ * @return boolean
190
  */
191
  public function put($remoteFile, $localFile, $mode = FTP_BINARY, $startPos = 0)
192
  {
194
  return @ftp_put($this->_conn, $remoteFile, $localFile, $mode, $startPos);
195
  }
196
 
 
197
  /**
198
  * Get current working directory
199
+ *
200
+ * @return string
201
  */
202
  public function getcwd()
203
  {
218
 
219
  /**
220
  * ftp_raw wrapper
221
+ *
222
  * @param string $cmd
223
+ * @return array
224
  */
225
  public function raw($cmd)
226
  {
228
  return @ftp_raw($this->_conn, $cmd);
229
  }
230
 
 
231
  /**
232
+ * Upload local file to remote server.
 
233
  * Can be used for relative and absoulte remote paths
234
  * Relative: use chdir before calling this
235
  *
236
+ * @param string $remote
237
  * @param string $local
238
  * @param int $dirMode
239
  * @param int $fileMode
240
+ * @return boolean
241
  */
242
  public function upload($remote, $local, $dirMode = 0777, $fileMode=0)
243
  {
279
  if($fileMode){
280
  $res=$this->chmod($fileMode, $remote);
281
  }
282
+ return (boolean)$res;
283
  }
284
 
285
  /**
286
  * Download remote file to local machine
287
+ *
288
  * @param string $remote
289
  * @param string $local
290
  * @param int $ftpMode FTP_BINARY|FTP_ASCII
291
+ * @return boolean
292
  */
293
  public function download($remote, $local, $ftpMode = FTP_BINARY)
294
  {
296
  return $this->get($local, $remote, $ftpMode);
297
  }
298
 
 
299
  /**
300
  * ftp_pasv wrapper
301
+ *
302
+ * @param boolean $pasv
303
+ * @return boolean
304
  */
305
  public function pasv($pasv)
306
  {
307
  $this->checkConnected();
308
+ return @ftp_pasv($this->_conn, (boolean) $pasv);
309
  }
310
 
311
  /**
312
  * Close FTP connection
313
+ *
314
+ * @return null
315
  */
316
  public function close()
317
  {
322
 
323
  /**
324
  * ftp_chmod wrapper
325
+ *
326
  * @param $mode
327
  * @param $remoteFile
328
+ * @return boolean
329
  */
330
  public function chmod($mode, $remoteFile)
331
  {
335
 
336
  /**
337
  * ftp_chdir wrapper
338
+ *
339
  * @param string $dir
340
+ * @return boolean
341
  */
342
  public function chdir($dir)
343
  {
347
 
348
  /**
349
  * ftp_cdup wrapper
350
+ *
351
+ * @return boolean
352
  */
353
  public function cdup()
354
  {
358
 
359
  /**
360
  * ftp_get wrapper
361
+ *
362
  * @param string $localFile
363
  * @param string $remoteFile
364
  * @param int $fileMode FTP_BINARY | FTP_ASCII
365
  * @param int $resumeOffset
366
+ * @return boolean
367
  */
368
  public function get($localFile, $remoteFile, $fileMode = FTP_BINARY, $resumeOffset = 0)
369
  {
374
 
375
  /**
376
  * ftp_nlist wrapper
377
+ *
378
  * @param string $dir
379
+ * @return boolean
380
  */
381
  public function nlist($dir = "/")
382
  {
387
 
388
  /**
389
  * ftp_rawlist wrapper
390
+ *
391
  * @param string $dir
392
+ * @param boolean $recursive
393
+ * @return array
394
  */
395
  public function rawlist( $dir = "/", $recursive = false )
396
  {
399
  return @ftp_rawlist($this->_conn, $dir, $recursive);
400
  }
401
 
 
402
  /**
403
  * Convert byte count to float KB/MB format
404
+ *
405
  * @param int $bytes
406
  * @return string
407
  */
414
 
415
  /**
416
  * Chmod string "-rwxrwxrwx" to "777" converter
417
+ *
418
  * @param string $chmod
419
  * @return string
420
  */
430
  * Checks file exists
431
  *
432
  * @param string $path
433
+ * @param boolean $excludeIfIsDir
434
+ * @return boolean
435
  */
436
  public function fileExists($path, $excludeIfIsDir = true)
437
  {
454
 
455
  /**
456
  * Get directory contents in PHP array
457
+ *
458
  * @param string $dir
459
+ * @param boolean $recursive
460
  * @return array
461
  */
462
  public function ls($dir = "/", $recursive = false)
494
 
495
  /**
496
  * Correct file path
497
+ *
498
  * @param $str
499
  * @return string
500
  */
507
 
508
  /**
509
  * Delete file
510
+ *
511
  * @param string $file
512
+ * @return boolean
513
  */
514
  public function delete($file)
515
  {
520
 
521
  /**
522
  * Remove directory
523
+ *
524
  * @param string $dir
525
+ * @return boolean
526
  */
527
  public function rmdir($dir)
528
  {
downloader/lib/Mage/Connect/Loader.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
 
@@ -33,11 +33,11 @@
33
  */
34
  class Mage_Connect_Loader
35
  {
36
-
37
  /**
38
  * Factory for HTTP client
39
- * @param string/false $protocol 'curl'/'socket' or false for auto-detect
40
- * @return Mage_HTTP_Client/Mage_Connect_Loader_Ftp
 
41
  */
42
  public static function getInstance($protocol='')
43
  {
@@ -47,5 +47,4 @@ class Mage_Connect_Loader
47
  return Mage_HTTP_Client::getInstance();
48
  }
49
  }
50
-
51
  }
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
 
33
  */
34
  class Mage_Connect_Loader
35
  {
 
36
  /**
37
  * Factory for HTTP client
38
+ *
39
+ * @param string|false $protocol 'curl'/'socket' or false for auto-detect
40
+ * @return Mage_HTTP_IClient|Mage_Connect_Loader_Ftp
41
  */
42
  public static function getInstance($protocol='')
43
  {
47
  return Mage_HTTP_Client::getInstance();
48
  }
49
  }
 
50
  }
downloader/lib/Mage/Connect/Loader/Ftp.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/Connect/Package.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/Connect/Package/Hotfix.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/Connect/Package/Reader.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/Connect/Package/Target.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/Connect/Package/VO.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/Connect/Package/Writer.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/Connect/Packager.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
 
@@ -261,7 +261,7 @@ class Mage_Connect_Packager
261
  $contents = $package->getContents();
262
 
263
  $targetPath = rtrim($configObj->magento_root, "\\/");
264
- foreach($contents as $file) {
265
  $fileName = basename($file);
266
  $filePath = dirname($file);
267
  $dest = $targetPath . DIRECTORY_SEPARATOR . $filePath . DIRECTORY_SEPARATOR . $fileName;
@@ -290,7 +290,7 @@ class Mage_Connect_Packager
290
  $ftpDir = $ftp->getcwd();
291
  $package = $cacheObj->getPackageObject($chanName, $package);
292
  $contents = $package->getContents();
293
- foreach($contents as $file) {
294
  $ftp->delete($file);
295
  $this->removeEmptyDirectory(dirname($file), $ftp);
296
  }
@@ -317,7 +317,7 @@ class Mage_Connect_Packager
317
  /**
318
  * Return correct global dir mode in octal representation
319
  *
320
- * @param Maged_Model_Config $config
321
  * @return int
322
  */
323
  protected function _getDirMode($config)
@@ -332,7 +332,7 @@ class Mage_Connect_Packager
332
  /**
333
  * Return global file mode in octal representation
334
  *
335
- * @param Maged_Model_Config $config
336
  * @return int
337
  */
338
  protected function _getFileMode($config)
@@ -360,7 +360,7 @@ class Mage_Connect_Packager
360
  *
361
  * @param Mage_Connect_Package $package
362
  * @param string $file
363
- * @param Maged_Model_Config $configObj
364
  * @param Mage_Connect_Ftp $ftp
365
  * @return void
366
  */
@@ -369,13 +369,13 @@ class Mage_Connect_Packager
369
  $ftpDir = $ftp->getcwd();
370
  $contents = $package->getContents();
371
  $arc = $this->getArchiver();
372
- $target = dirname($file).DS.$package->getReleaseFilename();
373
  @mkdir($target, 0777, true);
374
  $tar = $arc->unpack($file, $target);
375
  $modeFile = $this->_getFileMode($configObj);
376
  $modeDir = $this->_getDirMode($configObj);
377
- foreach($contents as $file) {
378
- $source = $tar.DS.$file;
379
  if (file_exists($source) && is_file($source)) {
380
  $args = array(ltrim($file,"/"), $source);
381
  if($modeDir||$modeFile) {
@@ -401,23 +401,23 @@ class Mage_Connect_Packager
401
  *
402
  * @param Mage_Connect_Package $package
403
  * @param string $file
 
404
  * @return void
405
- * @throws Exception
406
  */
407
  public function processInstallPackage($package, $file, $configObj)
408
  {
409
  $contents = $package->getContents();
410
  $arc = $this->getArchiver();
411
- $target = dirname($file).DS.$package->getReleaseFilename();
412
  @mkdir($target, 0777, true);
413
  $tar = $arc->unpack($file, $target);
414
  $modeFile = $this->_getFileMode($configObj);
415
  $modeDir = $this->_getDirMode($configObj);
416
  $targetPath = rtrim($configObj->magento_root, "\\/");
417
- foreach($contents as $file) {
418
  $fileName = basename($file);
419
  $filePath = dirname($file);
420
- $source = $tar.DS.$file;
421
  @mkdir($targetPath. DS . $filePath, $modeDir, true);
422
  $dest = $targetPath . DS . $filePath . DS . $fileName;
423
  if (is_file($source)) {
@@ -496,8 +496,9 @@ class Mage_Connect_Packager
496
  /**
497
  * Get upgrades list
498
  *
499
- * @param string/array $channels
500
  * @param Mage_Connect_Singleconfig $cacheObject
 
501
  * @param Mage_Connect_Rest $restObj optional
502
  * @param bool $checkConflicts
503
  * @return array
@@ -513,7 +514,7 @@ class Mage_Connect_Packager
513
  }
514
 
515
  $updates = array();
516
- foreach($channels as $chan) {
517
 
518
  if(!$cacheObject->isChannel($chan)) {
519
  continue;
@@ -536,14 +537,14 @@ class Mage_Connect_Packager
536
  */
537
  $state = $configObj->preferred_state ? $configObj->preferred_state : "stable";
538
 
539
- foreach($localPackages as $localName=>$localData) {
540
  if(!isset($remotePackages[$localName])) {
541
  continue;
542
  }
543
  $package = $remotePackages[$localName];
544
  $neededToUpgrade = false;
545
  $remoteVersion = $localVersion = trim($localData[Mage_Connect_Singleconfig::K_VER]);
546
- foreach($package as $version => $s) {
547
 
548
  if($cacheObject->compareStabilities($s, $state) < 0) {
549
  continue;
@@ -581,7 +582,7 @@ class Mage_Connect_Packager
581
  * @param Mage_Connect_Singleconfig $cache
582
  * @param Mage_Connect_Config $config
583
  * @param bool $withDepsRecursive
584
- * @return array
585
  */
586
  public function getUninstallList($chanName, $package, $cache, $config, $withDepsRecursive = true)
587
  {
@@ -599,7 +600,7 @@ class Mage_Connect_Packager
599
  $hash = array();
600
  return array('list'=>array());
601
  }
602
- return;
603
  }
604
  $dependencies = $cache->getPackageDependencies($chanName, $package);
605
  $data = $cache->getPackage($chanName, $package);
@@ -614,14 +615,14 @@ class Mage_Connect_Packager
614
 
615
  if($withDepsRecursive) {
616
  $fields = array('name','channel','min','max');
617
- foreach($dependencies as $row) {
618
  /**
619
  * Converts an array to variables
620
  * @var $pChannel string Channel Name
621
  * @var $pName string Package Name
622
  */
623
- foreach($fields as $key) {
624
- $varName = "p".ucfirst($key);
625
  $$varName = $row[$key];
626
  }
627
  $method = __FUNCTION__;
@@ -642,6 +643,8 @@ class Mage_Connect_Packager
642
  $hash = array();
643
  return array('list'=>$out);
644
  }
 
 
645
  }
646
 
647
  /**
@@ -656,7 +659,7 @@ class Mage_Connect_Packager
656
  * @param string $versionMax Required package maximum version
657
  * @param string $installState Package install state
658
  * @param string $message Package install message
659
- * @param array $dependencies Package dependencies
660
  * @return bool
661
  */
662
  private function addHashData(&$hash, $name, $channel, $downloaded_version = '', $stability = '', $versionMin = '',
@@ -677,7 +680,7 @@ class Mage_Connect_Packager
677
  'max' => $versionMax,
678
  'install_state' => $installState,
679
  'message' => (isset($this->installStates[$installState]) ?
680
- $this->installStates[$installState] : '').$message,
681
  'packages' => $dependencies,
682
  );
683
  return true;
@@ -713,7 +716,7 @@ class Mage_Connect_Packager
713
  try {
714
  $chanName = $cache->chanName($chanName);
715
 
716
- if (!$rest){
717
  $rest = new Mage_Connect_Rest($config->protocol);
718
  }
719
  $rest->setChannel($cache->chanUrl($chanName));
@@ -739,6 +742,7 @@ class Mage_Connect_Packager
739
  if (!$version) {
740
  $versionState = $cache->detectVersionFromRestArray($releases, $versionMin, $versionMax);
741
  if ($versionState) {
 
742
  $packageInfo = $rest->getPackageReleaseInfo($package, $versionState);
743
  if (false !== $packageInfo) {
744
  $stability = $packageInfo->getStability();
@@ -758,7 +762,7 @@ class Mage_Connect_Packager
758
  * check is package already installed
759
  */
760
  if ($installedPackage = $cache->isPackageInstalled($package)) {
761
- if ($chanName == $installedPackage['channel']){
762
  /**
763
  * check versions
764
  */
@@ -808,7 +812,7 @@ class Mage_Connect_Packager
808
 
809
  if ($withDepsRecursive && self::INSTALL_STATE_INCOMPATIBLE != $install_state) {
810
  $flds = array('name','channel','min','max');
811
- foreach($dependencies as $row) {
812
  /**
813
  * Converts an array to variables
814
  * @var $pChannel string Channel Name
@@ -816,13 +820,13 @@ class Mage_Connect_Packager
816
  * @var $pMax string Maximum version number
817
  * @var $pMin string Minimum version number
818
  */
819
- foreach($flds as $key) {
820
- $varName = "p".ucfirst($key);
821
  $$varName = $row[$key];
822
  }
823
  $method = __FUNCTION__;
824
  /**
825
- * @todo When we are building dependencies tree we should base this calculations not on full key as
826
  * on a unique value but check it by parts. First part which should be checked is EXTENSION_NAME
827
  * also this part should be unique globally not per channel.
828
  */
@@ -844,7 +848,7 @@ class Mage_Connect_Packager
844
  }
845
 
846
  $names = array("pMin","pMax","hasMin","hasMax");
847
- for($i=0, $c=count($names); $i<$c; $i++) {
848
  if(!isset($$names[$i])) {
849
  continue;
850
  }
@@ -896,8 +900,9 @@ class Mage_Connect_Packager
896
  $_failed = array();
897
  return array('deps' => $deps, 'result' => $out, 'failed'=> $failed);
898
  }
899
- }
900
 
 
 
901
 
902
  /**
903
  * Process dependencies hash. Makes topological sorting and gives operation order list
@@ -911,8 +916,7 @@ class Mage_Connect_Packager
911
  $nodes = array();
912
  $graph = new Mage_Connect_Structures_Graph();
913
 
914
- foreach($depsHash as $key=>$data) {
915
- $packages = $data['packages'];
916
  $node = new Mage_Connect_Structures_Node();
917
  $nodes[$key] =& $node;
918
  unset($data['packages']);
@@ -921,12 +925,12 @@ class Mage_Connect_Packager
921
  unset($node);
922
  }
923
 
924
- if(count($nodes) > 1) {
925
- foreach($depsHash as $key=>$data) {
926
  $packages = $data['packages'];
927
- foreach($packages as $pdata) {
928
  $pName = $pdata['name'];
929
- if(isset($nodes[$key], $nodes[$pName])) {
930
  $nodes[$key]->connectTo($nodes[$pName]);
931
  }
932
  }
@@ -940,8 +944,9 @@ class Mage_Connect_Packager
940
  $result = $graph->topologicalSort();
941
  $sortReverse ? krsort($result) : ksort($result);
942
  $out = array();
943
- foreach($result as $nodes) {
944
- foreach($nodes as $n) {
 
945
  $out[] = $n->getData();
946
  }
947
  }
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
 
261
  $contents = $package->getContents();
262
 
263
  $targetPath = rtrim($configObj->magento_root, "\\/");
264
+ foreach ($contents as $file) {
265
  $fileName = basename($file);
266
  $filePath = dirname($file);
267
  $dest = $targetPath . DIRECTORY_SEPARATOR . $filePath . DIRECTORY_SEPARATOR . $fileName;
290
  $ftpDir = $ftp->getcwd();
291
  $package = $cacheObj->getPackageObject($chanName, $package);
292
  $contents = $package->getContents();
293
+ foreach ($contents as $file) {
294
  $ftp->delete($file);
295
  $this->removeEmptyDirectory(dirname($file), $ftp);
296
  }
317
  /**
318
  * Return correct global dir mode in octal representation
319
  *
320
+ * @param Mage_Connect_Config $config
321
  * @return int
322
  */
323
  protected function _getDirMode($config)
332
  /**
333
  * Return global file mode in octal representation
334
  *
335
+ * @param Mage_Connect_Config $config
336
  * @return int
337
  */
338
  protected function _getFileMode($config)
360
  *
361
  * @param Mage_Connect_Package $package
362
  * @param string $file
363
+ * @param Mage_Connect_Config $configObj
364
  * @param Mage_Connect_Ftp $ftp
365
  * @return void
366
  */
369
  $ftpDir = $ftp->getcwd();
370
  $contents = $package->getContents();
371
  $arc = $this->getArchiver();
372
+ $target = dirname($file) . DS . $package->getReleaseFilename();
373
  @mkdir($target, 0777, true);
374
  $tar = $arc->unpack($file, $target);
375
  $modeFile = $this->_getFileMode($configObj);
376
  $modeDir = $this->_getDirMode($configObj);
377
+ foreach ($contents as $file) {
378
+ $source = $tar . DS . $file;
379
  if (file_exists($source) && is_file($source)) {
380
  $args = array(ltrim($file,"/"), $source);
381
  if($modeDir||$modeFile) {
401
  *
402
  * @param Mage_Connect_Package $package
403
  * @param string $file
404
+ * @param Mage_Connect_Config $configObj
405
  * @return void
 
406
  */
407
  public function processInstallPackage($package, $file, $configObj)
408
  {
409
  $contents = $package->getContents();
410
  $arc = $this->getArchiver();
411
+ $target = dirname($file) . DS . $package->getReleaseFilename();
412
  @mkdir($target, 0777, true);
413
  $tar = $arc->unpack($file, $target);
414
  $modeFile = $this->_getFileMode($configObj);
415
  $modeDir = $this->_getDirMode($configObj);
416
  $targetPath = rtrim($configObj->magento_root, "\\/");
417
+ foreach ($contents as $file) {
418
  $fileName = basename($file);
419
  $filePath = dirname($file);
420
+ $source = $tar . DS . $file;
421
  @mkdir($targetPath. DS . $filePath, $modeDir, true);
422
  $dest = $targetPath . DS . $filePath . DS . $fileName;
423
  if (is_file($source)) {
496
  /**
497
  * Get upgrades list
498
  *
499
+ * @param string|array $channels
500
  * @param Mage_Connect_Singleconfig $cacheObject
501
+ * @param Mage_Connect_Config $configObj
502
  * @param Mage_Connect_Rest $restObj optional
503
  * @param bool $checkConflicts
504
  * @return array
514
  }
515
 
516
  $updates = array();
517
+ foreach ($channels as $chan) {
518
 
519
  if(!$cacheObject->isChannel($chan)) {
520
  continue;
537
  */
538
  $state = $configObj->preferred_state ? $configObj->preferred_state : "stable";
539
 
540
+ foreach ($localPackages as $localName=>$localData) {
541
  if(!isset($remotePackages[$localName])) {
542
  continue;
543
  }
544
  $package = $remotePackages[$localName];
545
  $neededToUpgrade = false;
546
  $remoteVersion = $localVersion = trim($localData[Mage_Connect_Singleconfig::K_VER]);
547
+ foreach ($package as $version => $s) {
548
 
549
  if($cacheObject->compareStabilities($s, $state) < 0) {
550
  continue;
582
  * @param Mage_Connect_Singleconfig $cache
583
  * @param Mage_Connect_Config $config
584
  * @param bool $withDepsRecursive
585
+ * @return array|null
586
  */
587
  public function getUninstallList($chanName, $package, $cache, $config, $withDepsRecursive = true)
588
  {
600
  $hash = array();
601
  return array('list'=>array());
602
  }
603
+ return null;
604
  }
605
  $dependencies = $cache->getPackageDependencies($chanName, $package);
606
  $data = $cache->getPackage($chanName, $package);
615
 
616
  if($withDepsRecursive) {
617
  $fields = array('name','channel','min','max');
618
+ foreach ($dependencies as $row) {
619
  /**
620
  * Converts an array to variables
621
  * @var $pChannel string Channel Name
622
  * @var $pName string Package Name
623
  */
624
+ foreach ($fields as $key) {
625
+ $varName = "p" . ucfirst($key);
626
  $$varName = $row[$key];
627
  }
628
  $method = __FUNCTION__;
643
  $hash = array();
644
  return array('list'=>$out);
645
  }
646
+
647
+ return null;
648
  }
649
 
650
  /**
659
  * @param string $versionMax Required package maximum version
660
  * @param string $installState Package install state
661
  * @param string $message Package install message
662
+ * @param array|string $dependencies Package dependencies
663
  * @return bool
664
  */
665
  private function addHashData(&$hash, $name, $channel, $downloaded_version = '', $stability = '', $versionMin = '',
680
  'max' => $versionMax,
681
  'install_state' => $installState,
682
  'message' => (isset($this->installStates[$installState]) ?
683
+ $this->installStates[$installState] : '') . $message,
684
  'packages' => $dependencies,
685
  );
686
  return true;
716
  try {
717
  $chanName = $cache->chanName($chanName);
718
 
719
+ if (!$rest) {
720
  $rest = new Mage_Connect_Rest($config->protocol);
721
  }
722
  $rest->setChannel($cache->chanUrl($chanName));
742
  if (!$version) {
743
  $versionState = $cache->detectVersionFromRestArray($releases, $versionMin, $versionMax);
744
  if ($versionState) {
745
+ /** @var $packageInfo Mage_Connect_Package */
746
  $packageInfo = $rest->getPackageReleaseInfo($package, $versionState);
747
  if (false !== $packageInfo) {
748
  $stability = $packageInfo->getStability();
762
  * check is package already installed
763
  */
764
  if ($installedPackage = $cache->isPackageInstalled($package)) {
765
+ if ($chanName == $installedPackage['channel']) {
766
  /**
767
  * check versions
768
  */
812
 
813
  if ($withDepsRecursive && self::INSTALL_STATE_INCOMPATIBLE != $install_state) {
814
  $flds = array('name','channel','min','max');
815
+ foreach ($dependencies as $row) {
816
  /**
817
  * Converts an array to variables
818
  * @var $pChannel string Channel Name
820
  * @var $pMax string Maximum version number
821
  * @var $pMin string Minimum version number
822
  */
823
+ foreach ($flds as $key) {
824
+ $varName = "p" . ucfirst($key);
825
  $$varName = $row[$key];
826
  }
827
  $method = __FUNCTION__;
828
  /**
829
+ * When we are building dependencies tree we should base this calculations not on full key as
830
  * on a unique value but check it by parts. First part which should be checked is EXTENSION_NAME
831
  * also this part should be unique globally not per channel.
832
  */
848
  }
849
 
850
  $names = array("pMin","pMax","hasMin","hasMax");
851
+ for ($i=0, $c=count($names); $i<$c; $i++) {
852
  if(!isset($$names[$i])) {
853
  continue;
854
  }
900
  $_failed = array();
901
  return array('deps' => $deps, 'result' => $out, 'failed'=> $failed);
902
  }
 
903
 
904
+ return null;
905
+ }
906
 
907
  /**
908
  * Process dependencies hash. Makes topological sorting and gives operation order list
916
  $nodes = array();
917
  $graph = new Mage_Connect_Structures_Graph();
918
 
919
+ foreach ($depsHash as $key=>$data) {
 
920
  $node = new Mage_Connect_Structures_Node();
921
  $nodes[$key] =& $node;
922
  unset($data['packages']);
925
  unset($node);
926
  }
927
 
928
+ if (count($nodes) > 1) {
929
+ foreach ($depsHash as $key=>$data) {
930
  $packages = $data['packages'];
931
+ foreach ($packages as $pdata) {
932
  $pName = $pdata['name'];
933
+ if (isset($nodes[$key], $nodes[$pName])) {
934
  $nodes[$key]->connectTo($nodes[$pName]);
935
  }
936
  }
944
  $result = $graph->topologicalSort();
945
  $sortReverse ? krsort($result) : ksort($result);
946
  $out = array();
947
+ foreach ($result as $nodes) {
948
+ foreach ($nodes as $n) {
949
+ /** @var $n Mage_Connect_Structures_Node */
950
  $out[] = $n->getData();
951
  }
952
  }
downloader/lib/Mage/Connect/Rest.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
 
@@ -31,10 +31,11 @@
31
  * @package Mage_Connect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
-
35
  class Mage_Connect_Rest
36
  {
37
-
 
 
38
  const CHANNELS_XML = "channels.xml";
39
  const CHANNEL_XML = "channel.xml";
40
  const PACKAGES_XML = "packages.xml";
@@ -48,28 +49,38 @@ class Mage_Connect_Rest
48
  */
49
  protected $_loader = null;
50
 
51
-
52
  /**
53
  * XML parser
 
54
  * @var Mage_Xml_Parser
55
  */
56
  protected $_parser = null;
57
 
58
  /**
59
  * Channel URI
 
60
  * @var string
61
  */
62
  protected $_chanUri = '';
63
 
64
  /**
65
- * Protocol HTTP or FTP
66
- *
67
- * @var string http or ftp
68
- */
69
  protected $_protocol = '';
70
 
71
  /**
72
- * Constructor
 
 
 
 
 
 
 
 
 
73
  */
74
  public function __construct($protocol="http")
75
  {
@@ -87,10 +98,10 @@ class Mage_Connect_Rest
87
  }
88
 
89
  /**
90
- * Set channel info
91
  *
92
  * @param string $uri
93
- * @param sting $name
94
  */
95
  public function setChannel($uri)
96
  {
@@ -99,17 +110,17 @@ class Mage_Connect_Rest
99
 
100
  /**
101
  * Get HTTP loader
102
- * @return Mage_Connect_Loader
 
103
  */
104
  public function getLoader()
105
  {
106
- if(is_null($this->_loader)) {
107
  $this->_loader = Mage_Connect_Loader::getInstance($this->_protocol);
108
  }
109
  return $this->_loader;
110
  }
111
 
112
-
113
  /**
114
  * Get parser
115
  *
@@ -117,7 +128,7 @@ class Mage_Connect_Rest
117
  */
118
  protected function getParser()
119
  {
120
- if(is_null($this->_parser)) {
121
  $this->_parser = new Mage_Xml_Parser();
122
  }
123
  return $this->_parser;
@@ -125,15 +136,16 @@ class Mage_Connect_Rest
125
 
126
  /**
127
  * Load URI response
128
- * @param string $uri
 
 
129
  */
130
  protected function loadChannelUri($uriSuffix)
131
  {
132
- $url = $this->_chanUri."/".$uriSuffix;
133
- //print $url."\n";
134
  $this->getLoader()->get($url);
135
  $statusCode = $this->getLoader()->getStatus();
136
- if($statusCode != 200) {
137
  return false;
138
  }
139
  return $this->getLoader()->getBody();
@@ -141,79 +153,82 @@ class Mage_Connect_Rest
141
 
142
  /**
143
  * Get channels list of URI
 
144
  * @return array
145
  */
146
  public function getChannelInfo()
147
  {
148
  $out = $this->loadChannelUri(self::CHANNEL_XML);
149
  $statusCode = $this->getLoader()->getStatus();
150
- if($statusCode != 200) {
151
  throw new Exception("Invalid server response for {$this->_chanUri}");
152
  }
153
  $parser = $this->getParser();
154
  $out = $parser->loadXML($out)->xmlToArray();
155
 
156
- // TODO: add channel validator
157
  $vo = new Mage_Connect_Channel_VO();
158
  $vo->fromArray($out['channel']);
159
- if(!$vo->validate()) {
160
  throw new Exception("Invalid channel.xml file");
161
  }
162
  return $vo;
163
  }
164
 
165
-
166
  /**
167
  * Get packages list of channel
 
168
  * @return array
169
  */
170
  public function getPackages()
171
  {
172
  $out = $this->loadChannelUri(self::PACKAGES_XML);
173
  $statusCode = $this->getLoader()->getStatus();
174
- if($statusCode != 200) {
175
  return false;
176
  }
177
  $parser = $this->getParser();
178
  $out = $parser->loadXML($out)->xmlToArray();
179
 
180
-
181
- if(!isset($out['data']['p'])) {
182
  return array();
183
  }
184
- if(isset($out['data']['p'][0])) {
185
  return $out['data']['p'];
186
  }
187
- if(is_array($out['data']['p'])) {
188
  return array($out['data']['p']);
189
  }
190
  return array();
191
  }
192
 
193
-
 
 
 
 
194
  public function getPackagesHashed()
195
  {
196
  $out = $this->loadChannelUri(self::PACKAGES_XML);
197
  $statusCode = $this->getLoader()->getStatus();
198
- if($statusCode != 200) {
199
  return false;
200
  }
201
  $parser = $this->getParser();
202
  $out = $parser->loadXML($out)->xmlToArray();
203
 
204
  $return = array();
205
- if(!isset($out['data']['p'])) {
206
  return $return;
207
  }
208
- if(isset($out['data']['p'][0])) {
209
  $return = $out['data']['p'];
210
- }elseif(is_array($out['data']['p'])) {
211
  $return = array($out['data']['p']);
212
  }
213
- $c = count($return);
214
- if($c) {
215
  $output = array();
216
- for($i=0; $i<$c; $i++) {
217
  $element = $return[$i];
218
  $output[$element['n']] = $element['r'];
219
  }
@@ -221,7 +236,7 @@ class Mage_Connect_Rest
221
  }
222
 
223
  $out = array();
224
- foreach($return as $name=>$package) {
225
  $stabilities = array_map(array($this, 'shortStateToLong'), array_keys($package));
226
  $versions = array_map('trim', array_values($package));
227
  $package = array_combine($versions, $stabilities);
@@ -233,6 +248,7 @@ class Mage_Connect_Rest
233
 
234
  /**
235
  * Stub
 
236
  * @param $n
237
  * @return unknown_type
238
  */
@@ -243,22 +259,24 @@ class Mage_Connect_Rest
243
 
244
  /**
245
  * Get releases list of package on current channel
 
246
  * @param string $package package name
 
247
  */
248
  public function getReleases($package)
249
  {
250
- $out = $this->loadChannelUri($this->escapePackageName($package)."/".self::RELEASES_XML);
251
  $statusCode = $this->getLoader()->getStatus();
252
- if($statusCode != 200) {
253
  return false;
254
  }
255
  $parser = $this->getParser();
256
  $out = $parser->loadXML($out)->xmlToArray();
257
- if(!isset($out['releases']['r'])) {
258
  return array();
259
  }
260
  $src = $out['releases']['r'];
261
- if(!array_key_exists(0, $src)) {
262
  return array($src);
263
  }
264
  $this->sortReleases($src);
@@ -267,6 +285,7 @@ class Mage_Connect_Rest
267
 
268
  /**
269
  * Sort releases
 
270
  * @param array $releases
271
  * @return void
272
  */
@@ -278,6 +297,7 @@ class Mage_Connect_Rest
278
 
279
  /**
280
  * Sort releases callback
 
281
  * @param string $a
282
  * @param srting $b
283
  * @return int
@@ -295,23 +315,24 @@ class Mage_Connect_Rest
295
  */
296
  public function getPackageInfo($package)
297
  {
298
- $out = $this->loadChannelUri($this->escapePackageName($package)."/".self::PACKAGE_XML);
299
- if(false === $out) {
300
  return false;
301
  }
302
  return new Mage_Connect_Package($out);
303
  }
304
 
305
  /**
 
306
  *
307
  * @param $package
308
  * @param $version
309
- * @return Mage_Connect_Package
310
  */
311
  public function getPackageReleaseInfo($package, $version)
312
  {
313
- $out = $this->loadChannelUri($this->escapePackageName($package)."/".$version."/".self::PACKAGE_XML);
314
- if(false === $out) {
315
  return false;
316
  }
317
  return new Mage_Connect_Package($out);
@@ -319,48 +340,51 @@ class Mage_Connect_Rest
319
 
320
  /**
321
  * Get package archive file of release
 
 
322
  * @param string $package package name
323
- * @param string $version version
 
 
324
  */
325
  public function downloadPackageFileOfRelease($package, $version, $targetFile)
326
  {
327
  $package = $this->escapePackageName($package);
328
  $version = $this->escapePackageName($version);
329
 
330
-
331
- if(file_exists($targetFile)) {
332
- $chksum = $this->loadChannelUri($package."/".$version."/checksum");
333
  $statusCode = $this->getLoader()->getStatus();
334
- if($statusCode == 200) {
335
- if(md5_file($targetFile) == $chksum) {
336
  return true;
337
  }
338
  }
339
  }
340
 
341
-
342
- $out = $this->loadChannelUri($package."/".$version."/".$package."-".$version.".".self::EXT);
343
 
344
  $statusCode = $this->getLoader()->getStatus();
345
- if($statusCode != 200) {
346
  throw new Exception("Package not found: {$package} {$version}");
347
  }
348
  $dir = dirname($targetFile);
349
  @mkdir($dir, 0777, true);
350
  $result = @file_put_contents($targetFile, $out);
351
- if(false === $result) {
352
  throw new Exception("Cannot write to file {$targetFile}");
353
  }
354
  return true;
355
  }
356
 
357
- protected $states = array('b'=>'beta', 'd'=>'dev', 's'=>'stable', 'a'=>'alpha');
358
-
 
 
 
 
359
  public function shortStateToLong($s)
360
  {
361
  return isset($this->states[$s]) ? $this->states[$s] : 'dev';
362
  }
363
-
364
-
365
  }
366
-
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
 
31
  * @package Mage_Connect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
 
34
  class Mage_Connect_Rest
35
  {
36
+ /**
37
+ * Paths for xml config files
38
+ */
39
  const CHANNELS_XML = "channels.xml";
40
  const CHANNEL_XML = "channel.xml";
41
  const PACKAGES_XML = "packages.xml";
49
  */
50
  protected $_loader = null;
51
 
 
52
  /**
53
  * XML parser
54
+ *
55
  * @var Mage_Xml_Parser
56
  */
57
  protected $_parser = null;
58
 
59
  /**
60
  * Channel URI
61
+ *
62
  * @var string
63
  */
64
  protected $_chanUri = '';
65
 
66
  /**
67
+ * Protocol HTTP or FTP
68
+ *
69
+ * @var string http or ftp
70
+ */
71
  protected $_protocol = '';
72
 
73
  /**
74
+ * States interpretation
75
+ *
76
+ * @var array
77
+ */
78
+ protected $states = array('b'=>'beta', 'd'=>'dev', 's'=>'stable', 'a'=>'alpha');
79
+
80
+ /**
81
+ * Constructor sets default protocol
82
+ *
83
+ * @param string $protocol
84
  */
85
  public function __construct($protocol="http")
86
  {
98
  }
99
 
100
  /**
101
+ * Set channel URI
102
  *
103
  * @param string $uri
104
+ * @return void
105
  */
106
  public function setChannel($uri)
107
  {
110
 
111
  /**
112
  * Get HTTP loader
113
+ *
114
+ * @return Mage_HTTP_IClient|Mage_Connect_Loader_Ftp
115
  */
116
  public function getLoader()
117
  {
118
+ if (is_null($this->_loader)) {
119
  $this->_loader = Mage_Connect_Loader::getInstance($this->_protocol);
120
  }
121
  return $this->_loader;
122
  }
123
 
 
124
  /**
125
  * Get parser
126
  *
128
  */
129
  protected function getParser()
130
  {
131
+ if (is_null($this->_parser)) {
132
  $this->_parser = new Mage_Xml_Parser();
133
  }
134
  return $this->_parser;
136
 
137
  /**
138
  * Load URI response
139
+ *
140
+ * @param string $uriSuffix
141
+ * @return bool|string
142
  */
143
  protected function loadChannelUri($uriSuffix)
144
  {
145
+ $url = $this->_chanUri . "/" . $uriSuffix;
 
146
  $this->getLoader()->get($url);
147
  $statusCode = $this->getLoader()->getStatus();
148
+ if ($statusCode != 200) {
149
  return false;
150
  }
151
  return $this->getLoader()->getBody();
153
 
154
  /**
155
  * Get channels list of URI
156
+ *
157
  * @return array
158
  */
159
  public function getChannelInfo()
160
  {
161
  $out = $this->loadChannelUri(self::CHANNEL_XML);
162
  $statusCode = $this->getLoader()->getStatus();
163
+ if ($statusCode != 200) {
164
  throw new Exception("Invalid server response for {$this->_chanUri}");
165
  }
166
  $parser = $this->getParser();
167
  $out = $parser->loadXML($out)->xmlToArray();
168
 
 
169
  $vo = new Mage_Connect_Channel_VO();
170
  $vo->fromArray($out['channel']);
171
+ if (!$vo->validate()) {
172
  throw new Exception("Invalid channel.xml file");
173
  }
174
  return $vo;
175
  }
176
 
 
177
  /**
178
  * Get packages list of channel
179
+ *
180
  * @return array
181
  */
182
  public function getPackages()
183
  {
184
  $out = $this->loadChannelUri(self::PACKAGES_XML);
185
  $statusCode = $this->getLoader()->getStatus();
186
+ if ($statusCode != 200) {
187
  return false;
188
  }
189
  $parser = $this->getParser();
190
  $out = $parser->loadXML($out)->xmlToArray();
191
 
192
+ if (!isset($out['data']['p'])) {
 
193
  return array();
194
  }
195
+ if (isset($out['data']['p'][0])) {
196
  return $out['data']['p'];
197
  }
198
+ if (is_array($out['data']['p'])) {
199
  return array($out['data']['p']);
200
  }
201
  return array();
202
  }
203
 
204
+ /**
205
+ * Return Channel Packages loaded from Channel Server
206
+ *
207
+ * @return array|bool|string
208
+ */
209
  public function getPackagesHashed()
210
  {
211
  $out = $this->loadChannelUri(self::PACKAGES_XML);
212
  $statusCode = $this->getLoader()->getStatus();
213
+ if ($statusCode != 200) {
214
  return false;
215
  }
216
  $parser = $this->getParser();
217
  $out = $parser->loadXML($out)->xmlToArray();
218
 
219
  $return = array();
220
+ if (!isset($out['data']['p'])) {
221
  return $return;
222
  }
223
+ if (isset($out['data']['p'][0])) {
224
  $return = $out['data']['p'];
225
+ } elseif (is_array($out['data']['p'])) {
226
  $return = array($out['data']['p']);
227
  }
228
+ $c = count($return);
229
+ if ($c) {
230
  $output = array();
231
+ for ($i=0; $i<$c; $i++) {
232
  $element = $return[$i];
233
  $output[$element['n']] = $element['r'];
234
  }
236
  }
237
 
238
  $out = array();
239
+ foreach ($return as $name=>$package) {
240
  $stabilities = array_map(array($this, 'shortStateToLong'), array_keys($package));
241
  $versions = array_map('trim', array_values($package));
242
  $package = array_combine($versions, $stabilities);
248
 
249
  /**
250
  * Stub
251
+ *
252
  * @param $n
253
  * @return unknown_type
254
  */
259
 
260
  /**
261
  * Get releases list of package on current channel
262
+ *
263
  * @param string $package package name
264
+ * @return array|bool
265
  */
266
  public function getReleases($package)
267
  {
268
+ $out = $this->loadChannelUri($this->escapePackageName($package) . "/" . self::RELEASES_XML);
269
  $statusCode = $this->getLoader()->getStatus();
270
+ if ($statusCode != 200) {
271
  return false;
272
  }
273
  $parser = $this->getParser();
274
  $out = $parser->loadXML($out)->xmlToArray();
275
+ if (!isset($out['releases']['r'])) {
276
  return array();
277
  }
278
  $src = $out['releases']['r'];
279
+ if (!array_key_exists(0, $src)) {
280
  return array($src);
281
  }
282
  $this->sortReleases($src);
285
 
286
  /**
287
  * Sort releases
288
+ *
289
  * @param array $releases
290
  * @return void
291
  */
297
 
298
  /**
299
  * Sort releases callback
300
+ *
301
  * @param string $a
302
  * @param srting $b
303
  * @return int
315
  */
316
  public function getPackageInfo($package)
317
  {
318
+ $out = $this->loadChannelUri($this->escapePackageName($package) . "/" . self::PACKAGE_XML);
319
+ if (false === $out) {
320
  return false;
321
  }
322
  return new Mage_Connect_Package($out);
323
  }
324
 
325
  /**
326
+ * Retrieve information on Package Release from the Channel Server
327
  *
328
  * @param $package
329
  * @param $version
330
+ * @return Mage_Connect_Package|bool
331
  */
332
  public function getPackageReleaseInfo($package, $version)
333
  {
334
+ $out = $this->loadChannelUri($this->escapePackageName($package) . "/" . $version . "/" . self::PACKAGE_XML);
335
+ if (false === $out) {
336
  return false;
337
  }
338
  return new Mage_Connect_Package($out);
340
 
341
  /**
342
  * Get package archive file of release
343
+ *
344
+ * @throws Exception
345
  * @param string $package package name
346
+ * @param string $version package version
347
+ * @param string $targetFile
348
+ * @return bool
349
  */
350
  public function downloadPackageFileOfRelease($package, $version, $targetFile)
351
  {
352
  $package = $this->escapePackageName($package);
353
  $version = $this->escapePackageName($version);
354
 
355
+ if (file_exists($targetFile)) {
356
+ $chksum = $this->loadChannelUri($package . "/" . $version . "/checksum");
 
357
  $statusCode = $this->getLoader()->getStatus();
358
+ if ($statusCode == 200) {
359
+ if (md5_file($targetFile) == $chksum) {
360
  return true;
361
  }
362
  }
363
  }
364
 
365
+ $out = $this->loadChannelUri($package . "/" . $version . "/" . $package . "-" . $version . "." . self::EXT);
 
366
 
367
  $statusCode = $this->getLoader()->getStatus();
368
+ if ($statusCode != 200) {
369
  throw new Exception("Package not found: {$package} {$version}");
370
  }
371
  $dir = dirname($targetFile);
372
  @mkdir($dir, 0777, true);
373
  $result = @file_put_contents($targetFile, $out);
374
+ if (false === $result) {
375
  throw new Exception("Cannot write to file {$targetFile}");
376
  }
377
  return true;
378
  }
379
 
380
+ /**
381
+ * Decode state
382
+ *
383
+ * @param string $s
384
+ * @return string
385
+ */
386
  public function shortStateToLong($s)
387
  {
388
  return isset($this->states[$s]) ? $this->states[$s] : 'dev';
389
  }
 
 
390
  }
 
downloader/lib/Mage/Connect/Singleconfig.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
 
@@ -31,36 +31,40 @@
31
  * @package Mage_Connect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
-
35
  class Mage_Connect_Singleconfig
36
  {
37
  /**
38
  * Default single config filename
 
39
  * 'cache.cfg'
40
  */
41
  const DEFAULT_SCONFIG_FILENAME = 'cache.cfg';
42
 
43
  /**
44
  * Cache data
 
45
  * @var array
46
  */
47
  protected $_data = array();
48
 
49
  /**
50
  * Filename
 
51
  * @var string
52
  */
53
  protected $_readFilename = false;
54
 
55
  /**
 
56
  *
57
- * @var unknown_type
58
  */
59
  protected $_debug = false;
60
 
61
  /**
 
62
  *
63
- * @var unknown_type
64
  */
65
  protected $_validator;
66
 
@@ -81,6 +85,27 @@ class Mage_Connect_Singleconfig
81
  const K_PACK_DEPS = 'pack_deps';
82
  const K_CONFIG = 'config';
83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  public function getValidUri($str)
85
  {
86
  $data = @parse_url($str);
@@ -90,11 +115,22 @@ class Mage_Connect_Singleconfig
90
  return false;
91
  }
92
 
 
 
 
 
 
93
  public function getFilename()
94
  {
95
  return $this->_readFilename;
96
  }
97
 
 
 
 
 
 
 
98
  public function formatUri($uri)
99
  {
100
  $uri = rtrim($uri, "/");
@@ -106,32 +142,19 @@ class Mage_Connect_Singleconfig
106
 
107
  /**
108
  * Get data
109
- * @return unknown_type
 
110
  */
111
  public function getData()
112
  {
113
  return $this->_data;
114
  }
115
 
116
- /**
117
- * Constructor
118
- * @param srting $file
119
- * @return void
120
- */
121
- public function __construct($file = self::DEFAULT_SCONFIG_FILENAME)
122
- {
123
- $this->setEmptyConfig();
124
- if($file) {
125
- $this->_readFilename = $file;
126
- $this->load();
127
- }
128
- }
129
-
130
-
131
  /**
132
  * Load cache from file
 
133
  * @param string $file
134
- * @return void
135
  */
136
  public function load($file = false)
137
  {
@@ -169,7 +192,6 @@ class Mage_Connect_Singleconfig
169
  return $this->doError("Cannot unserialize data in file contents: '{$file}'");
170
  }
171
 
172
-
173
  $validData = true;
174
  foreach(array_keys($this->_data) as $k) {
175
  if(!isset($data[$k])) {
@@ -187,8 +209,9 @@ class Mage_Connect_Singleconfig
187
 
188
  /**
189
  * Save contents
 
190
  * @param string $file
191
- * @return void
192
  */
193
  public function save($file = false)
194
  {
@@ -213,19 +236,21 @@ class Mage_Connect_Singleconfig
213
 
214
  /**
215
  * Set empty config skeleton
216
- * @return void
 
217
  */
218
  public function setEmptyConfig()
219
  {
220
  $this->_data = array(
221
- self::K_CHAN => array (),
222
- self::K_CHAN_URI => array (),
223
- self::K_CHAN_ALIAS => array (),
224
  );
225
  }
226
 
227
  /**
228
  * Check channel, add if valid name and not exist
 
229
  * @param string $chanName
230
  * @param Mage_Connect_Config $config
231
  * @param Mage_Connect_Rest $rest
@@ -237,8 +262,6 @@ class Mage_Connect_Singleconfig
237
  return true;
238
  }
239
 
240
- $uri = '';
241
-
242
  $_validator = new Mage_Connect_Validator();
243
  if ($this->isChannelName($chanName)) {
244
  $uri = $this->chanUrl($chanName);
@@ -263,6 +286,12 @@ class Mage_Connect_Singleconfig
263
  return $this->isChannel($uri);
264
  }
265
 
 
 
 
 
 
 
266
  public function isChannel($chanName)
267
  {
268
  if($this->isChannelName($chanName)) {
@@ -279,6 +308,7 @@ class Mage_Connect_Singleconfig
279
 
280
  /**
281
  * Get channel
 
282
  * @param string $chanName
283
  * @return array
284
  */
@@ -296,8 +326,9 @@ class Mage_Connect_Singleconfig
296
 
297
  /**
298
  * Is channel name?
 
299
  * @param $chanName
300
- * @return bool
301
  */
302
  public function isChannelName($chanName)
303
  {
@@ -306,8 +337,9 @@ class Mage_Connect_Singleconfig
306
 
307
  /**
308
  * Is channel alias?
 
309
  * @param string $chanName
310
- * @return bool
311
  */
312
  public function isChannelAlias($chanName)
313
  {
@@ -316,8 +348,9 @@ class Mage_Connect_Singleconfig
316
 
317
  /**
318
  * Is channel uri?
 
319
  * @param $uri
320
- * @return bool
321
  */
322
  public function isChannelUri($uri)
323
  {
@@ -327,8 +360,9 @@ class Mage_Connect_Singleconfig
327
 
328
  /**
329
  * Unset channel uri record
 
330
  * @param string $uri
331
- * @return void
332
  */
333
  protected function unsetChannelUriRecord($uri)
334
  {
@@ -338,9 +372,10 @@ class Mage_Connect_Singleconfig
338
 
339
  /**
340
  * Set channel uri record: uri maps to channel record
 
341
  * @param string $chanName
342
  * @param string $uri
343
- * @return void
344
  */
345
  protected function setChannelUriRecord($chanName, $uri)
346
  {
@@ -350,6 +385,7 @@ class Mage_Connect_Singleconfig
350
 
351
  /**
352
  * Get channel name by uri record
 
353
  * @param string $uri
354
  * @return string
355
  */
@@ -359,11 +395,11 @@ class Mage_Connect_Singleconfig
359
  return $this->_data[self::K_CHAN_URI][$uri];
360
  }
361
 
362
-
363
  /**
364
  * Unset channel record
 
365
  * @param string $chanName
366
- * @return void
367
  */
368
  protected function unsetChannelRecord($chanName)
369
  {
@@ -372,6 +408,7 @@ class Mage_Connect_Singleconfig
372
 
373
  /**
374
  * Get channel record
 
375
  * @param string $chanName
376
  * @return array
377
  */
@@ -382,28 +419,30 @@ class Mage_Connect_Singleconfig
382
 
383
  /**
384
  * Set channel record
 
385
  * @param string $chanName
386
  * @param string $uri
387
  * @param mixed $data
388
  * @param array $packages
389
- * @return void
390
  */
391
  protected function setChannelRecord($chanName, $uri, $data, $packages = array())
392
  {
393
  $this->_data[self::K_CHAN][$chanName] = array(
394
- self::K_NAME=>$chanName,
395
- self::K_URI=>$uri,
396
- self::K_CHAN_DATA=>$data,
397
- self::K_PACK=>$packages
398
  );
399
  }
400
 
401
  /**
402
  * Set package record
 
403
  * @param string $chanName
404
  * @param string $packageName
405
  * @param mixed $data
406
- * @return void
407
  */
408
  protected function setPackageRecord($chanName, $packageName, $data, $oneField = null)
409
  {
@@ -418,9 +457,10 @@ class Mage_Connect_Singleconfig
418
 
419
  /**
420
  * Unset package record
 
421
  * @param string $chanName
422
  * @param string $packageName
423
- * @return void
424
  */
425
  protected function unsetPackageRecord($chanName, $packageName)
426
  {
@@ -445,9 +485,10 @@ class Mage_Connect_Singleconfig
445
 
446
  /**
447
  * Has package record
 
448
  * @param string $chanName
449
  * @param string $packageName
450
- * @return bool
451
  */
452
  protected function hasPackageRecord($chanName, $packageName)
453
  {
@@ -466,9 +507,10 @@ class Mage_Connect_Singleconfig
466
 
467
  /**
468
  * Set channel alias
 
469
  * @param string $alias
470
  * @param string $chanName
471
- * @return void
472
  */
473
  protected function setChannelAlias($alias, $chanName)
474
  {
@@ -477,8 +519,9 @@ class Mage_Connect_Singleconfig
477
 
478
  /**
479
  * Unset channel alias
 
480
  * @param string $alias
481
- * @return void
482
  */
483
  protected function unsetChannelAlias($alias)
484
  {
@@ -487,8 +530,9 @@ class Mage_Connect_Singleconfig
487
 
488
  /**
489
  * Clear all aliases of channel
 
490
  * @param string $chanName channel name
491
- * @return void
492
  */
493
  protected function clearAliases($chanName)
494
  {
@@ -502,9 +546,10 @@ class Mage_Connect_Singleconfig
502
 
503
  /**
504
  * Add channel alias
 
505
  * @param string $chanName
506
  * @param string $alias
507
- * @return void
508
  */
509
  public function addChannelAlias($chanName, $alias)
510
  {
@@ -519,14 +564,13 @@ class Mage_Connect_Singleconfig
519
  $this->save();
520
  }
521
 
522
-
523
-
524
  /**
525
  * Add channel
526
- * @param $chanName
527
- * @param $uri
528
- * @param $data
529
- * @return void
 
530
  */
531
  public function addChannel($chanName, $uri, $data = array())
532
  {
@@ -545,12 +589,11 @@ class Mage_Connect_Singleconfig
545
  $this->save();
546
  }
547
 
548
-
549
-
550
  /**
551
  * Delete channel
552
- * @param $chanName
553
- * @return void
 
554
  */
555
  public function deleteChannel($chanName)
556
  {
@@ -573,11 +616,11 @@ class Mage_Connect_Singleconfig
573
  $this->save();
574
  }
575
 
576
-
577
  /**
578
  * Converts channel name, url or alias to channel name
579
  * throws exception if not found
580
- * @param srting $chanName
 
581
  * @return string
582
  */
583
  public function chanName($chanName)
@@ -589,6 +632,12 @@ class Mage_Connect_Singleconfig
589
  return $channelData[self::K_NAME];
590
  }
591
 
 
 
 
 
 
 
592
  public function chanUrl($chan)
593
  {
594
  $channelData = $this->getChannel($chan);
@@ -598,11 +647,11 @@ class Mage_Connect_Singleconfig
598
  return $channelData[self::K_URI];
599
  }
600
 
601
-
602
  /**
603
  * Add package
 
604
  * @param Mage_Connect_Package $package
605
- * @return void
606
  */
607
  public function addPackage($package)
608
  {
@@ -621,14 +670,12 @@ class Mage_Connect_Singleconfig
621
  $this->save();
622
  }
623
 
624
-
625
-
626
-
627
  /**
628
  * Delete package
 
629
  * @param string $chanName
630
  * @param string $package
631
- * @return void
632
  */
633
  public function deletePackage($chanName, $package)
634
  {
@@ -639,9 +686,10 @@ class Mage_Connect_Singleconfig
639
 
640
  /**
641
  * Get package
642
- * @param sting $chanName
 
643
  * @param string $package
644
- * @return void
645
  */
646
  public function getPackage($chanName, $package)
647
  {
@@ -652,6 +700,14 @@ class Mage_Connect_Singleconfig
652
  return null;
653
  }
654
 
 
 
 
 
 
 
 
 
655
  public function getPackageObject($chanName, $package)
656
  {
657
  $chanName = $this->chanName($chanName);
@@ -662,7 +718,15 @@ class Mage_Connect_Singleconfig
662
  throw new Exception("Cannot get package: '{$package}'");
663
  }
664
 
665
-
 
 
 
 
 
 
 
 
666
  public function hasPackage($chanName, $package, $versionMin = false, $versionMax = false)
667
  {
668
  $chanName = $this->chanName($chanName);
@@ -678,7 +742,7 @@ class Mage_Connect_Singleconfig
678
  * Check whether package installed or not. Return package if it installed
679
  *
680
  * @param string $package package name
681
- * @return array
682
  */
683
  public function isPackageInstalled($package)
684
  {
@@ -698,7 +762,7 @@ class Mage_Connect_Singleconfig
698
  * @param string $version
699
  * @param string $versionMin
700
  * @param string $versionMax
701
- * @return bool
702
  */
703
  public function versionInRange($version, $versionMin = false, $versionMax = false)
704
  {
@@ -731,7 +795,8 @@ class Mage_Connect_Singleconfig
731
 
732
  /**
733
  * Clear contents to defaults and save
734
- * @return void
 
735
  */
736
  public function clear()
737
  {
@@ -741,19 +806,23 @@ class Mage_Connect_Singleconfig
741
 
742
  /**
743
  * Output error - throw exception
 
744
  * @param $message
745
  * @throws Exception
746
- * @return void
747
  */
748
  protected function doError($message)
749
  {
750
  throw new Exception($message);
751
  }
752
 
753
-
754
-
755
-
756
-
 
 
 
757
  public function compareStabilities($s1, $s2)
758
  {
759
  if(!$this->_validator) {
@@ -762,12 +831,18 @@ class Mage_Connect_Singleconfig
762
  return $this->_validator->compareStabilities($s1, $s2);
763
  }
764
 
765
-
766
-
 
 
 
 
 
 
 
767
  public function detectVersionFromRestArray($restData, $argVersionMin = false, $argVersionMax = false,
768
  $preferredStability = 'devel')
769
  {
770
-
771
  if(!is_array($restData)) {
772
  return false;
773
  }
@@ -783,7 +858,14 @@ class Mage_Connect_Singleconfig
783
  return false;
784
  }
785
 
786
-
 
 
 
 
 
 
 
787
  public function setPackageDependencies($chanName, $package, $data)
788
  {
789
  $chanName = $this->chanName($chanName);
@@ -795,6 +877,13 @@ class Mage_Connect_Singleconfig
795
  return false;
796
  }
797
 
 
 
 
 
 
 
 
798
  public function getPackageDependencies($chanName, $package)
799
  {
800
  $chanName = $this->chanName($chanName);
@@ -804,8 +893,14 @@ class Mage_Connect_Singleconfig
804
  return false;
805
  }
806
 
807
-
808
-
 
 
 
 
 
 
809
  public function setDependencyInfo($chanName, $package, $data)
810
  {
811
  $chanName = $this->chanName($chanName);
@@ -817,6 +912,13 @@ class Mage_Connect_Singleconfig
817
  return false;
818
  }
819
 
 
 
 
 
 
 
 
820
  public function getDependencyInfo($chanName, $package)
821
  {
822
  $chanName = $this->chanName($chanName);
@@ -826,11 +928,22 @@ class Mage_Connect_Singleconfig
826
  return false;
827
  }
828
 
 
 
 
 
 
829
  public function getChannelNames()
830
  {
831
  return array_keys($this->_data[self::K_CHAN]);
832
  }
833
 
 
 
 
 
 
 
834
  public function getPackagesData($channel = false)
835
  {
836
  if(false == $channel) {
@@ -843,6 +956,14 @@ class Mage_Connect_Singleconfig
843
  return $this->getChannel($channel);
844
  }
845
 
 
 
 
 
 
 
 
 
846
  public function specifiedInDependencyList($deps, $chanName, $packageName)
847
  {
848
  foreach($deps as $dep) {
@@ -853,6 +974,14 @@ class Mage_Connect_Singleconfig
853
  return false;
854
  }
855
 
 
 
 
 
 
 
 
 
856
  public function requiredByOtherPackages($chanName, $packageName, $excludeList = array())
857
  {
858
  $out = array();
@@ -870,8 +999,15 @@ class Mage_Connect_Singleconfig
870
  return $out;
871
  }
872
 
 
 
 
 
 
 
873
  public function getInstalledPackages($chanName = false)
874
  {
 
875
  if(false == $chanName) {
876
  $data = $this->getChannelNames();
877
  } elseif($this->isChannel($chanName)) {
@@ -879,7 +1015,7 @@ class Mage_Connect_Singleconfig
879
  $data = array($tmp[self::K_NAME]);
880
  }
881
  $out = array();
882
- foreach( $data as $chanName) {
883
  $channel = $this->getChannel($chanName);
884
  $out[$chanName] = array();
885
  foreach($channel[self::K_PACK] as $package=>$data) {
@@ -901,21 +1037,13 @@ class Mage_Connect_Singleconfig
901
  * @param string $chanName
902
  * @param string $packageName
903
  * @param string $version
904
- * @return array|false
905
  */
906
  public function hasConflicts($chanName, $packageName, $version)
907
  {
908
  $conflicts = array();
909
  foreach($this->_data[self::K_CHAN] as $channel=>$data) {
910
  foreach($data[self::K_PACK] as $package) {
911
- /**
912
- * @todo When we are building dependencies tree we should base this calculations not on full key as on
913
- * a unique value but check it by parts. First part which should be checked is EXTENSION_NAME also this
914
- * part should be unique globally not per channel.
915
- */
916
- /*if($channel != $chanName) {
917
- continue;
918
- }*/
919
  $deps = $package[self::K_PACK_DEPS];
920
  foreach($deps as $dep) {
921
  if($dep['name'] != $packageName) {
@@ -923,7 +1051,6 @@ class Mage_Connect_Singleconfig
923
  }
924
 
925
  if(!$this->versionInRange($version, $dep['min'], $dep['max'])) {
926
- //var_dump($version, $dep['min'], $dep['max']);
927
  $conflicts[] = $channel . "/". $package['name'] ." ". $package['version'];
928
  }
929
  }
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
 
31
  * @package Mage_Connect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
 
34
  class Mage_Connect_Singleconfig
35
  {
36
  /**
37
  * Default single config filename
38
+ *
39
  * 'cache.cfg'
40
  */
41
  const DEFAULT_SCONFIG_FILENAME = 'cache.cfg';
42
 
43
  /**
44
  * Cache data
45
+ *
46
  * @var array
47
  */
48
  protected $_data = array();
49
 
50
  /**
51
  * Filename
52
+ *
53
  * @var string
54
  */
55
  protected $_readFilename = false;
56
 
57
  /**
58
+ * Debug flag
59
  *
60
+ * @var boolean
61
  */
62
  protected $_debug = false;
63
 
64
  /**
65
+ * Validator instance
66
  *
67
+ * @var Mage_Connect_Validator
68
  */
69
  protected $_validator;
70
 
85
  const K_PACK_DEPS = 'pack_deps';
86
  const K_CONFIG = 'config';
87
 
88
+ /**
89
+ * Constructor
90
+ *
91
+ * @param string $file
92
+ * @return null
93
+ */
94
+ public function __construct($file = self::DEFAULT_SCONFIG_FILENAME)
95
+ {
96
+ $this->setEmptyConfig();
97
+ if($file) {
98
+ $this->_readFilename = $file;
99
+ $this->load();
100
+ }
101
+ }
102
+
103
+ /**
104
+ * Parse and return valid URL
105
+ *
106
+ * @param string $str
107
+ * @return string|boolean
108
+ */
109
  public function getValidUri($str)
110
  {
111
  $data = @parse_url($str);
115
  return false;
116
  }
117
 
118
+ /**
119
+ * Return config file name
120
+ *
121
+ * @return string
122
+ */
123
  public function getFilename()
124
  {
125
  return $this->_readFilename;
126
  }
127
 
128
+ /**
129
+ * Return formatted part of URI
130
+ *
131
+ * @param $uri
132
+ * @return string
133
+ */
134
  public function formatUri($uri)
135
  {
136
  $uri = rtrim($uri, "/");
142
 
143
  /**
144
  * Get data
145
+ *
146
+ * @return array
147
  */
148
  public function getData()
149
  {
150
  return $this->_data;
151
  }
152
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
  /**
154
  * Load cache from file
155
+ *
156
  * @param string $file
157
+ * @return null
158
  */
159
  public function load($file = false)
160
  {
192
  return $this->doError("Cannot unserialize data in file contents: '{$file}'");
193
  }
194
 
 
195
  $validData = true;
196
  foreach(array_keys($this->_data) as $k) {
197
  if(!isset($data[$k])) {
209
 
210
  /**
211
  * Save contents
212
+ *
213
  * @param string $file
214
+ * @return null
215
  */
216
  public function save($file = false)
217
  {
236
 
237
  /**
238
  * Set empty config skeleton
239
+ *
240
+ * @return null
241
  */
242
  public function setEmptyConfig()
243
  {
244
  $this->_data = array(
245
+ self::K_CHAN => array (),
246
+ self::K_CHAN_URI => array (),
247
+ self::K_CHAN_ALIAS => array (),
248
  );
249
  }
250
 
251
  /**
252
  * Check channel, add if valid name and not exist
253
+ *
254
  * @param string $chanName
255
  * @param Mage_Connect_Config $config
256
  * @param Mage_Connect_Rest $rest
262
  return true;
263
  }
264
 
 
 
265
  $_validator = new Mage_Connect_Validator();
266
  if ($this->isChannelName($chanName)) {
267
  $uri = $this->chanUrl($chanName);
286
  return $this->isChannel($uri);
287
  }
288
 
289
+ /**
290
+ * Check Channel name
291
+ *
292
+ * @param $chanName
293
+ * @return boolean
294
+ */
295
  public function isChannel($chanName)
296
  {
297
  if($this->isChannelName($chanName)) {
308
 
309
  /**
310
  * Get channel
311
+ *
312
  * @param string $chanName
313
  * @return array
314
  */
326
 
327
  /**
328
  * Is channel name?
329
+ *
330
  * @param $chanName
331
+ * @return boolean
332
  */
333
  public function isChannelName($chanName)
334
  {
337
 
338
  /**
339
  * Is channel alias?
340
+ *
341
  * @param string $chanName
342
+ * @return boolean
343
  */
344
  public function isChannelAlias($chanName)
345
  {
348
 
349
  /**
350
  * Is channel uri?
351
+ *
352
  * @param $uri
353
+ * @return boolean
354
  */
355
  public function isChannelUri($uri)
356
  {
360
 
361
  /**
362
  * Unset channel uri record
363
+ *
364
  * @param string $uri
365
+ * @return null
366
  */
367
  protected function unsetChannelUriRecord($uri)
368
  {
372
 
373
  /**
374
  * Set channel uri record: uri maps to channel record
375
+ *
376
  * @param string $chanName
377
  * @param string $uri
378
+ * @return null
379
  */
380
  protected function setChannelUriRecord($chanName, $uri)
381
  {
385
 
386
  /**
387
  * Get channel name by uri record
388
+ *
389
  * @param string $uri
390
  * @return string
391
  */
395
  return $this->_data[self::K_CHAN_URI][$uri];
396
  }
397
 
 
398
  /**
399
  * Unset channel record
400
+ *
401
  * @param string $chanName
402
+ * @return null
403
  */
404
  protected function unsetChannelRecord($chanName)
405
  {
408
 
409
  /**
410
  * Get channel record
411
+ *
412
  * @param string $chanName
413
  * @return array
414
  */
419
 
420
  /**
421
  * Set channel record
422
+ *
423
  * @param string $chanName
424
  * @param string $uri
425
  * @param mixed $data
426
  * @param array $packages
427
+ * @return null
428
  */
429
  protected function setChannelRecord($chanName, $uri, $data, $packages = array())
430
  {
431
  $this->_data[self::K_CHAN][$chanName] = array(
432
+ self::K_NAME=>$chanName,
433
+ self::K_URI=>$uri,
434
+ self::K_CHAN_DATA=>$data,
435
+ self::K_PACK=>$packages
436
  );
437
  }
438
 
439
  /**
440
  * Set package record
441
+ *
442
  * @param string $chanName
443
  * @param string $packageName
444
  * @param mixed $data
445
+ * @return null
446
  */
447
  protected function setPackageRecord($chanName, $packageName, $data, $oneField = null)
448
  {
457
 
458
  /**
459
  * Unset package record
460
+ *
461
  * @param string $chanName
462
  * @param string $packageName
463
+ * @return null
464
  */
465
  protected function unsetPackageRecord($chanName, $packageName)
466
  {
485
 
486
  /**
487
  * Has package record
488
+ *
489
  * @param string $chanName
490
  * @param string $packageName
491
+ * @return boolean
492
  */
493
  protected function hasPackageRecord($chanName, $packageName)
494
  {
507
 
508
  /**
509
  * Set channel alias
510
+ *
511
  * @param string $alias
512
  * @param string $chanName
513
+ * @return null
514
  */
515
  protected function setChannelAlias($alias, $chanName)
516
  {
519
 
520
  /**
521
  * Unset channel alias
522
+ *
523
  * @param string $alias
524
+ * @return null
525
  */
526
  protected function unsetChannelAlias($alias)
527
  {
530
 
531
  /**
532
  * Clear all aliases of channel
533
+ *
534
  * @param string $chanName channel name
535
+ * @return null
536
  */
537
  protected function clearAliases($chanName)
538
  {
546
 
547
  /**
548
  * Add channel alias
549
+ *
550
  * @param string $chanName
551
  * @param string $alias
552
+ * @return null
553
  */
554
  public function addChannelAlias($chanName, $alias)
555
  {
564
  $this->save();
565
  }
566
 
 
 
567
  /**
568
  * Add channel
569
+ *
570
+ * @param string $chanName
571
+ * @param string $uri
572
+ * @param array $data
573
+ * @return null
574
  */
575
  public function addChannel($chanName, $uri, $data = array())
576
  {
589
  $this->save();
590
  }
591
 
 
 
592
  /**
593
  * Delete channel
594
+ *
595
+ * @param string $chanName
596
+ * @return null
597
  */
598
  public function deleteChannel($chanName)
599
  {
616
  $this->save();
617
  }
618
 
 
619
  /**
620
  * Converts channel name, url or alias to channel name
621
  * throws exception if not found
622
+ *
623
+ * @param string $chanName
624
  * @return string
625
  */
626
  public function chanName($chanName)
632
  return $channelData[self::K_NAME];
633
  }
634
 
635
+ /**
636
+ * Return Channel URI
637
+ *
638
+ * @param string $chan
639
+ * @return null
640
+ */
641
  public function chanUrl($chan)
642
  {
643
  $channelData = $this->getChannel($chan);
647
  return $channelData[self::K_URI];
648
  }
649
 
 
650
  /**
651
  * Add package
652
+ *
653
  * @param Mage_Connect_Package $package
654
+ * @return null
655
  */
656
  public function addPackage($package)
657
  {
670
  $this->save();
671
  }
672
 
 
 
 
673
  /**
674
  * Delete package
675
+ *
676
  * @param string $chanName
677
  * @param string $package
678
+ * @return null
679
  */
680
  public function deletePackage($chanName, $package)
681
  {
686
 
687
  /**
688
  * Get package
689
+ *
690
+ * @param string $chanName
691
  * @param string $package
692
+ * @return null
693
  */
694
  public function getPackage($chanName, $package)
695
  {
700
  return null;
701
  }
702
 
703
+ /**
704
+ * Retrieve Package object
705
+ *
706
+ * @throws Exception
707
+ * @param string $chanName
708
+ * @param string $package
709
+ * @return Mage_Connect_Package
710
+ */
711
  public function getPackageObject($chanName, $package)
712
  {
713
  $chanName = $this->chanName($chanName);
718
  throw new Exception("Cannot get package: '{$package}'");
719
  }
720
 
721
+ /**
722
+ * Checks the presence of the package in the channel
723
+ *
724
+ * @param string $chanName
725
+ * @param string $package
726
+ * @param string $versionMin
727
+ * @param string $versionMax
728
+ * @return boolean
729
+ */
730
  public function hasPackage($chanName, $package, $versionMin = false, $versionMax = false)
731
  {
732
  $chanName = $this->chanName($chanName);
742
  * Check whether package installed or not. Return package if it installed
743
  *
744
  * @param string $package package name
745
+ * @return array|boolean
746
  */
747
  public function isPackageInstalled($package)
748
  {
762
  * @param string $version
763
  * @param string $versionMin
764
  * @param string $versionMax
765
+ * @return boolean
766
  */
767
  public function versionInRange($version, $versionMin = false, $versionMax = false)
768
  {
795
 
796
  /**
797
  * Clear contents to defaults and save
798
+ *
799
+ * @return null
800
  */
801
  public function clear()
802
  {
806
 
807
  /**
808
  * Output error - throw exception
809
+ *
810
  * @param $message
811
  * @throws Exception
812
+ * @return null
813
  */
814
  protected function doError($message)
815
  {
816
  throw new Exception($message);
817
  }
818
 
819
+ /**
820
+ * Compare Stability
821
+ *
822
+ * @param string $s1
823
+ * @param string $s2
824
+ * @return int
825
+ */
826
  public function compareStabilities($s1, $s2)
827
  {
828
  if(!$this->_validator) {
831
  return $this->_validator->compareStabilities($s1, $s2);
832
  }
833
 
834
+ /**
835
+ * Retrieve Release Version from Rest Data
836
+ *
837
+ * @param $restData
838
+ * @param string|boolean $argVersionMin
839
+ * @param string|boolean $argVersionMax
840
+ * @param string $preferredStability
841
+ * @return boolean|string
842
+ */
843
  public function detectVersionFromRestArray($restData, $argVersionMin = false, $argVersionMax = false,
844
  $preferredStability = 'devel')
845
  {
 
846
  if(!is_array($restData)) {
847
  return false;
848
  }
858
  return false;
859
  }
860
 
861
+ /**
862
+ * Set Package dependencies
863
+ *
864
+ * @param string $chanName
865
+ * @param string $package
866
+ * @param mixed $data
867
+ * @return boolean
868
+ */
869
  public function setPackageDependencies($chanName, $package, $data)
870
  {
871
  $chanName = $this->chanName($chanName);
877
  return false;
878
  }
879
 
880
+ /**
881
+ * Retrieve Package Dependencies
882
+ *
883
+ * @param string $chanName
884
+ * @param string $package
885
+ * @return array|boolean
886
+ */
887
  public function getPackageDependencies($chanName, $package)
888
  {
889
  $chanName = $this->chanName($chanName);
893
  return false;
894
  }
895
 
896
+ /**
897
+ * Set Dependency information into package
898
+ *
899
+ * @param string $chanName
900
+ * @param string $package
901
+ * @param mixed $data
902
+ * @return boolean
903
+ */
904
  public function setDependencyInfo($chanName, $package, $data)
905
  {
906
  $chanName = $this->chanName($chanName);
912
  return false;
913
  }
914
 
915
+ /**
916
+ * Get Dependency information from package
917
+ *
918
+ * @param $chanName
919
+ * @param $package
920
+ * @return array|boolean
921
+ */
922
  public function getDependencyInfo($chanName, $package)
923
  {
924
  $chanName = $this->chanName($chanName);
928
  return false;
929
  }
930
 
931
+ /**
932
+ * Retrieve chanel names
933
+ *
934
+ * @return array
935
+ */
936
  public function getChannelNames()
937
  {
938
  return array_keys($this->_data[self::K_CHAN]);
939
  }
940
 
941
+ /**
942
+ * Retrieve Packages array
943
+ *
944
+ * @param string|boolean $channel
945
+ * @return array
946
+ */
947
  public function getPackagesData($channel = false)
948
  {
949
  if(false == $channel) {
956
  return $this->getChannel($channel);
957
  }
958
 
959
+ /**
960
+ * Check whether Package exists in dependency list
961
+ *
962
+ * @param array $deps
963
+ * @param string $chanName
964
+ * @param string $packageName
965
+ * @return boolean
966
+ */
967
  public function specifiedInDependencyList($deps, $chanName, $packageName)
968
  {
969
  foreach($deps as $dep) {
974
  return false;
975
  }
976
 
977
+ /**
978
+ * Checks is package required by other
979
+ *
980
+ * @param string $chanName
981
+ * @param string $packageName
982
+ * @param array $excludeList
983
+ * @return array
984
+ */
985
  public function requiredByOtherPackages($chanName, $packageName, $excludeList = array())
986
  {
987
  $out = array();
999
  return $out;
1000
  }
1001
 
1002
+ /**
1003
+ * Get Installed packages array
1004
+ *
1005
+ * @param string $chanName
1006
+ * @return array
1007
+ */
1008
  public function getInstalledPackages($chanName = false)
1009
  {
1010
+ $data = null;
1011
  if(false == $chanName) {
1012
  $data = $this->getChannelNames();
1013
  } elseif($this->isChannel($chanName)) {
1015
  $data = array($tmp[self::K_NAME]);
1016
  }
1017
  $out = array();
1018
+ foreach($data as $chanName) {
1019
  $channel = $this->getChannel($chanName);
1020
  $out[$chanName] = array();
1021
  foreach($channel[self::K_PACK] as $package=>$data) {
1037
  * @param string $chanName
1038
  * @param string $packageName
1039
  * @param string $version
1040
+ * @return array|boolean
1041
  */
1042
  public function hasConflicts($chanName, $packageName, $version)
1043
  {
1044
  $conflicts = array();
1045
  foreach($this->_data[self::K_CHAN] as $channel=>$data) {
1046
  foreach($data[self::K_PACK] as $package) {
 
 
 
 
 
 
 
 
1047
  $deps = $package[self::K_PACK_DEPS];
1048
  foreach($deps as $dep) {
1049
  if($dep['name'] != $packageName) {
1051
  }
1052
 
1053
  if(!$this->versionInRange($version, $dep['min'], $dep['max'])) {
 
1054
  $conflicts[] = $channel . "/". $package['name'] ." ". $package['version'];
1055
  }
1056
  }
downloader/lib/Mage/Connect/Structures/Graph.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/Connect/Structures/Node.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/Connect/Validator.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
 
@@ -31,50 +31,56 @@
31
  * @package Mage_Connect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
-
35
  class Mage_Connect_Validator
36
  {
 
 
 
 
 
37
  protected static $_stability = array(0=>'devel',1=>'alpha',2=>'beta',3=>'stable');
38
 
39
-
 
 
 
 
 
40
  public static function getStabilities()
41
  {
42
  return self::$_stability;
43
  }
44
 
45
-
46
-
47
  /**
48
  * Compare stabilities. Returns:
49
  *
50
  * -1 if the first stability is lower than the second
51
  * 0 if they are equal
52
  * 1 if the second is lower.
53
- * @param $s1
54
- * @param $s2
55
- * @return int
 
56
  */
57
  public function compareStabilities($s1, $s2)
58
  {
59
  $list = $this->getStabilities();
60
  $tmp = array_combine(array_values($list),array_keys($list));
61
 
62
- if(!isset($tmp[$s1], $tmp[$s2])) {
63
  throw new Exception("Invalid stability in compareStabilities argument");
64
  }
65
 
66
-
67
- // 'stable' turns to 3
68
- // 'devel' turns to 0
69
  $s1 = $tmp[$s1];
70
  $s2 = $tmp[$s2];
71
- if($s1 === $s2) {
72
  return 0;
73
- } elseif($s1 > $s2) {
74
  return 1;
75
- } elseif($s1 < $s2) {
76
  return -1;
77
  }
 
78
  }
79
 
80
  /**
@@ -87,6 +93,7 @@ class Mage_Connect_Validator
87
 
88
  /**
89
  * Validate max len of string
 
90
  * @param string $str
91
  * @param int $maxLen
92
  * @return bool
@@ -123,94 +130,103 @@ class Mage_Connect_Validator
123
 
124
  /**
125
  * Validate compatible data
 
126
  * @param array $data
127
  * @return bool
128
  */
129
  public function validateCompatible(array $data)
130
  {
131
- if(!count($data)) {
132
  /**
133
  * Allow empty
134
  */
135
  return true;
136
  }
137
  $count = 0;
138
- foreach($data as $k=>$v) {
139
- foreach(array('name','channel','min','max') as $fld) {
 
 
 
 
 
 
 
140
  $$fld = trim($v[$fld]);
141
- }
142
- $count++;
143
-
144
- $res = $this->validateUrl($channel) && strlen($channel);
145
- if(!$res) {
146
- $this->addError("Invalid or empty channel in compat. #{$count}");
147
- }
148
 
149
- $res = $this->validatePackageName($name) && strlen($name);
150
- if(!$res) {
151
- $this->addError("Invalid or empty name in compat. #{$count}");
152
- }
153
- $res1 = $this->validateVersion($min);
154
- if(!$res1) {
155
- $this->addError("Invalid or empty minVersion in compat. #{$count}");
156
- }
157
- $res2 = $this->validateVersion($max);
158
- if(!$res2) {
159
- $this->addError("Invalid or empty maxVersion in compat. #{$count}");
160
- }
161
- if($res1 && $res2 && $this->versionLower($max, $min)) {
162
- $this->addError("Max version is lower than min in compat #{$count}");
163
- }
164
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  }
166
- return ! $this->hasErrors();
167
  }
168
 
169
  /**
170
  * Validate authors of package
 
171
  * @param array $authors
172
  * @return bool
173
  */
174
  public function validateAuthors(array $authors)
175
  {
176
- if(!count($authors)) {
177
  $this->addError('Empty authors section');
178
  return false;
179
  }
180
  $count = 0;
181
- foreach($authors as $k=>$v) {
182
  $count++;
183
  array_map('trim', $v);
184
  $name = $v['name'];
185
  $login = $v['user'];
186
  $email = $v['email'];
187
  $res = $this->validateMaxLen($name, 256) && strlen($name);
188
- if(!$res) {
189
  $this->addError("Invalid or empty name for author #{$count}");
190
  }
191
- $res = $this->validatePackageName($login) && strlen($login);
192
- if(!$res) {
193
  $this->addError("Invalid or empty login for author #{$count}");
194
  }
195
  $res = $this->validateEmail($email);
196
- if(!$res) {
197
  $this->addError("Invalid or empty email for author #{$count}");
198
  }
199
  }
200
- return ! $this->hasErrors();
201
  }
202
 
203
-
204
  /**
205
  * Validator errors
 
206
  * @var array
207
  */
208
  private $_errors = array();
209
 
210
  /**
211
  * Add error
 
212
  * @param string $err
213
- * @return
214
  */
215
  private function addError($err)
216
  {
@@ -219,10 +235,10 @@ class Mage_Connect_Validator
219
 
220
  /**
221
  * Set validator errors
 
222
  * @param array $err
223
- * @return
224
  */
225
-
226
  private function setErrors(array $err)
227
  {
228
  $this->_errors = $err;
@@ -230,7 +246,8 @@ class Mage_Connect_Validator
230
 
231
  /**
232
  * Clear validator errors
233
- * @return
 
234
  */
235
  private function clearErrors()
236
  {
@@ -239,23 +256,24 @@ class Mage_Connect_Validator
239
 
240
  /**
241
  * Check if there are validator errors set
242
- * @return unknown_type
 
243
  */
244
  public function hasErrors()
245
  {
246
  return count($this->_errors) != 0;
247
  }
248
 
249
-
250
  /**
251
  * Get errors
 
252
  * @param bool $clear if true after this call erros will be cleared
253
  * @return array
254
  */
255
  public function getErrors($clear = true)
256
  {
257
  $out = $this->_errors;
258
- if($clear) {
259
  $this->clearErrors();
260
  }
261
  return $out;
@@ -263,6 +281,7 @@ class Mage_Connect_Validator
263
 
264
  /**
265
  * Validate URL
 
266
  * @param string $str
267
  * @return bool
268
  */
@@ -274,9 +293,9 @@ class Mage_Connect_Validator
274
  return preg_match($regex, $str);
275
  }
276
 
277
-
278
  /**
279
  * Validates package stability
 
280
  * @param string $str
281
  * @return bool
282
  */
@@ -287,6 +306,7 @@ class Mage_Connect_Validator
287
 
288
  /**
289
  * Validate date format
 
290
  * @param $date
291
  * @return bool
292
  */
@@ -294,13 +314,12 @@ class Mage_Connect_Validator
294
  {
295
  $subs = null;
296
  $check1 = preg_match("/^([\d]{4})-([\d]{2})-([\d]{2})$/i", $date, $subs);
297
- if(!$check1) {
298
  return false;
299
  }
300
  return checkdate($subs[2], $subs[3], $subs[1]);
301
  }
302
 
303
-
304
  /**
305
  * Validate email
306
  * @param string $email
@@ -321,8 +340,20 @@ class Mage_Connect_Validator
321
  return preg_match("/^[a-zA-Z0-9_]+$/i", $name);
322
  }
323
 
 
 
 
 
 
 
 
 
 
 
 
324
  /**
325
  * Validate version number
 
326
  * @param string $version
327
  * @return bool
328
  */
@@ -333,6 +364,7 @@ class Mage_Connect_Validator
333
 
334
  /**
335
  * Check versions are equal
 
336
  * @param string $v1
337
  * @param string $v2
338
  * @return bool
@@ -344,6 +376,7 @@ class Mage_Connect_Validator
344
 
345
  /**
346
  * Check version $v1 <= $v2
 
347
  * @param string $v1
348
  * @param string $v2
349
  * @return bool
@@ -353,9 +386,9 @@ class Mage_Connect_Validator
353
  return version_compare($v1, $v2, "le");
354
  }
355
 
356
-
357
  /**
358
  * Check if version $v1 lower than $v2
 
359
  * @param string $v1
360
  * @param string $v2
361
  * @return bool
@@ -367,6 +400,7 @@ class Mage_Connect_Validator
367
 
368
  /**
369
  * Check version $v1 >= $v2
 
370
  * @param string $v1
371
  * @param string $v2
372
  * @return bool
@@ -376,9 +410,9 @@ class Mage_Connect_Validator
376
  return version_compare($v1, $v2, "ge");
377
  }
378
 
379
-
380
  /**
381
  * Generic regex validation
 
382
  * @param string $str
383
  * @param string $regex
384
  * @return bool
@@ -388,9 +422,9 @@ class Mage_Connect_Validator
388
  return preg_match($regex, $str);
389
  }
390
 
391
-
392
  /**
393
  * Check if PHP extension loaded
 
394
  * @param string $name Extension name
395
  * @return bool
396
  */
@@ -399,15 +433,22 @@ class Mage_Connect_Validator
399
  return extension_loaded($name);
400
  }
401
 
402
-
 
 
 
 
 
 
 
403
  public function validatePHPVersion($min, $max, $ver = PHP_VERSION)
404
  {
405
  $minAccepted = true;
406
- if($min) {
407
  $minAccepted = version_compare($ver, $min, ">=");
408
  }
409
  $maxAccepted = true;
410
- if($max) {
411
  $maxAccepted = version_compare($ver, $max, "<=");
412
  }
413
  return (bool) $minAccepted && $maxAccepted;
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
 
31
  * @package Mage_Connect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
 
34
  class Mage_Connect_Validator
35
  {
36
+ /**
37
+ * Array of stability variants
38
+ *
39
+ * @var array
40
+ */
41
  protected static $_stability = array(0=>'devel',1=>'alpha',2=>'beta',3=>'stable');
42
 
43
+ /**
44
+ * Get array of Stability variants
45
+ *
46
+ * @static
47
+ * @return array
48
+ */
49
  public static function getStabilities()
50
  {
51
  return self::$_stability;
52
  }
53
 
 
 
54
  /**
55
  * Compare stabilities. Returns:
56
  *
57
  * -1 if the first stability is lower than the second
58
  * 0 if they are equal
59
  * 1 if the second is lower.
60
+ *
61
+ * @param int|string $s1
62
+ * @param int|string $s2
63
+ * @return int|null
64
  */
65
  public function compareStabilities($s1, $s2)
66
  {
67
  $list = $this->getStabilities();
68
  $tmp = array_combine(array_values($list),array_keys($list));
69
 
70
+ if (!isset($tmp[$s1], $tmp[$s2])) {
71
  throw new Exception("Invalid stability in compareStabilities argument");
72
  }
73
 
 
 
 
74
  $s1 = $tmp[$s1];
75
  $s2 = $tmp[$s2];
76
+ if ($s1 === $s2) {
77
  return 0;
78
+ } elseif ($s1 > $s2) {
79
  return 1;
80
+ } elseif ($s1 < $s2) {
81
  return -1;
82
  }
83
+ return null;
84
  }
85
 
86
  /**
93
 
94
  /**
95
  * Validate max len of string
96
+ *
97
  * @param string $str
98
  * @param int $maxLen
99
  * @return bool
130
 
131
  /**
132
  * Validate compatible data
133
+ *
134
  * @param array $data
135
  * @return bool
136
  */
137
  public function validateCompatible(array $data)
138
  {
139
+ if (!count($data)) {
140
  /**
141
  * Allow empty
142
  */
143
  return true;
144
  }
145
  $count = 0;
146
+ foreach ($data as $v) {
147
+ /**
148
+ * Converts an array to variables
149
+ * @var $channel string Channel Name
150
+ * @var $name string Package Name
151
+ * @var $max string Maximum version number
152
+ * @var $min string Minimum version number
153
+ */
154
+ foreach (array('name','channel','min','max') as $fld) {
155
  $$fld = trim($v[$fld]);
156
+ }
157
+ $count++;
 
 
 
 
 
158
 
159
+ $res = $this->validateUrl($channel) && strlen($channel);
160
+ if (!$res) {
161
+ $this->addError("Invalid or empty channel in compatibility #{$count}");
162
+ }
 
 
 
 
 
 
 
 
 
 
 
163
 
164
+ $res = $this->validatePackageName($name) && strlen($name);
165
+ if (!$res) {
166
+ $this->addError("Invalid or empty name in compatibility #{$count}");
167
+ }
168
+ $res1 = $this->validateVersion($min);
169
+ if (!$res1) {
170
+ $this->addError("Invalid or empty minVersion in compatibility #{$count}");
171
+ }
172
+ $res2 = $this->validateVersion($max);
173
+ if (!$res2) {
174
+ $this->addError("Invalid or empty maxVersion in compatibility #{$count}");
175
+ }
176
+ if ($res1 && $res2 && $this->versionLower($max, $min)) {
177
+ $this->addError("Max version is lower than min in compatibility #{$count}");
178
+ }
179
  }
180
+ return !$this->hasErrors();
181
  }
182
 
183
  /**
184
  * Validate authors of package
185
+ *
186
  * @param array $authors
187
  * @return bool
188
  */
189
  public function validateAuthors(array $authors)
190
  {
191
+ if (!count($authors)) {
192
  $this->addError('Empty authors section');
193
  return false;
194
  }
195
  $count = 0;
196
+ foreach ($authors as $v) {
197
  $count++;
198
  array_map('trim', $v);
199
  $name = $v['name'];
200
  $login = $v['user'];
201
  $email = $v['email'];
202
  $res = $this->validateMaxLen($name, 256) && strlen($name);
203
+ if (!$res) {
204
  $this->addError("Invalid or empty name for author #{$count}");
205
  }
206
+ $res = $this->validateAuthorName($login) && strlen($login);
207
+ if (!$res) {
208
  $this->addError("Invalid or empty login for author #{$count}");
209
  }
210
  $res = $this->validateEmail($email);
211
+ if (!$res) {
212
  $this->addError("Invalid or empty email for author #{$count}");
213
  }
214
  }
215
+ return !$this->hasErrors();
216
  }
217
 
 
218
  /**
219
  * Validator errors
220
+ *
221
  * @var array
222
  */
223
  private $_errors = array();
224
 
225
  /**
226
  * Add error
227
+ *
228
  * @param string $err
229
+ * @return void
230
  */
231
  private function addError($err)
232
  {
235
 
236
  /**
237
  * Set validator errors
238
+ *
239
  * @param array $err
240
+ * @return void
241
  */
 
242
  private function setErrors(array $err)
243
  {
244
  $this->_errors = $err;
246
 
247
  /**
248
  * Clear validator errors
249
+ *
250
+ * @return void
251
  */
252
  private function clearErrors()
253
  {
256
 
257
  /**
258
  * Check if there are validator errors set
259
+ *
260
+ * @return int
261
  */
262
  public function hasErrors()
263
  {
264
  return count($this->_errors) != 0;
265
  }
266
 
 
267
  /**
268
  * Get errors
269
+ *
270
  * @param bool $clear if true after this call erros will be cleared
271
  * @return array
272
  */
273
  public function getErrors($clear = true)
274
  {
275
  $out = $this->_errors;
276
+ if ($clear) {
277
  $this->clearErrors();
278
  }
279
  return $out;
281
 
282
  /**
283
  * Validate URL
284
+ *
285
  * @param string $str
286
  * @return bool
287
  */
293
  return preg_match($regex, $str);
294
  }
295
 
 
296
  /**
297
  * Validates package stability
298
+ *
299
  * @param string $str
300
  * @return bool
301
  */
306
 
307
  /**
308
  * Validate date format
309
+ *
310
  * @param $date
311
  * @return bool
312
  */
314
  {
315
  $subs = null;
316
  $check1 = preg_match("/^([\d]{4})-([\d]{2})-([\d]{2})$/i", $date, $subs);
317
+ if (!$check1) {
318
  return false;
319
  }
320
  return checkdate($subs[2], $subs[3], $subs[1]);
321
  }
322
 
 
323
  /**
324
  * Validate email
325
  * @param string $email
340
  return preg_match("/^[a-zA-Z0-9_]+$/i", $name);
341
  }
342
 
343
+ /**
344
+ * Validate author name
345
+ *
346
+ * @param string $name
347
+ * @return bool
348
+ */
349
+ public function validateAuthorName($name)
350
+ {
351
+ return preg_match("/^[a-zA-Z0-9_-]+$/i", $name);
352
+ }
353
+
354
  /**
355
  * Validate version number
356
+ *
357
  * @param string $version
358
  * @return bool
359
  */
364
 
365
  /**
366
  * Check versions are equal
367
+ *
368
  * @param string $v1
369
  * @param string $v2
370
  * @return bool
376
 
377
  /**
378
  * Check version $v1 <= $v2
379
+ *
380
  * @param string $v1
381
  * @param string $v2
382
  * @return bool
386
  return version_compare($v1, $v2, "le");
387
  }
388
 
 
389
  /**
390
  * Check if version $v1 lower than $v2
391
+ *
392
  * @param string $v1
393
  * @param string $v2
394
  * @return bool
400
 
401
  /**
402
  * Check version $v1 >= $v2
403
+ *
404
  * @param string $v1
405
  * @param string $v2
406
  * @return bool
410
  return version_compare($v1, $v2, "ge");
411
  }
412
 
 
413
  /**
414
  * Generic regex validation
415
+ *
416
  * @param string $str
417
  * @param string $regex
418
  * @return bool
422
  return preg_match($regex, $str);
423
  }
424
 
 
425
  /**
426
  * Check if PHP extension loaded
427
+ *
428
  * @param string $name Extension name
429
  * @return bool
430
  */
433
  return extension_loaded($name);
434
  }
435
 
436
+ /**
437
+ * Validate PHP version
438
+ *
439
+ * @param string $min
440
+ * @param string $max
441
+ * @param string $ver
442
+ * @return bool
443
+ */
444
  public function validatePHPVersion($min, $max, $ver = PHP_VERSION)
445
  {
446
  $minAccepted = true;
447
+ if ($min) {
448
  $minAccepted = version_compare($ver, $min, ">=");
449
  }
450
  $maxAccepted = true;
451
+ if ($max) {
452
  $maxAccepted = version_compare($ver, $max, "<=");
453
  }
454
  return (bool) $minAccepted && $maxAccepted;
downloader/lib/Mage/DB/Exception.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_DB
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_DB
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/DB/Mysqli.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_DB
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_DB
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/Exception.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_Exception
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_Exception
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/HTTP/Client.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_HTTP
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
 
@@ -31,10 +31,8 @@
31
  * @package Mage_Connect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
-
35
  class Mage_HTTP_Client
36
  {
37
-
38
  /**
39
  * Disallow to instantiate - pvt constructor
40
  */
@@ -43,24 +41,24 @@ class Mage_HTTP_Client
43
 
44
  }
45
 
46
-
47
  /**
48
  * Factory for HTTP client
49
- * @param string/false $frontend 'curl'/'socket' or false for auto-detect
 
 
 
50
  * @return Mage_HTTP_IClient
51
  */
52
  public static function getInstance($frontend = false)
53
  {
54
- if(false === $frontend)
55
- {
56
  $frontend = self::detectFrontend();
57
  }
58
- if(false === $frontend)
59
- {
60
  throw new Exception("Cannot find frontend automatically, set it manually");
61
  }
62
 
63
- $class = __CLASS__."_".str_replace(' ', DIRECTORY_SEPARATOR, ucwords(str_replace('_', ' ', $frontend)));
64
  $obj = new $class();
65
  return $obj;
66
  }
@@ -73,10 +71,10 @@ class Mage_HTTP_Client
73
  */
74
  protected static function detectFrontend()
75
  {
76
- if(function_exists("curl_init")) {
77
  return "curl";
78
  }
79
- if(function_exists("fsockopen")) {
80
  return "socket";
81
  }
82
  return false;
20
  *
21
  * @category Mage
22
  * @package Mage_HTTP
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
 
31
  * @package Mage_Connect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
 
34
  class Mage_HTTP_Client
35
  {
 
36
  /**
37
  * Disallow to instantiate - pvt constructor
38
  */
41
 
42
  }
43
 
 
44
  /**
45
  * Factory for HTTP client
46
+ *
47
+ * @static
48
+ * @throws Exception
49
+ * @param string|bool $frontend 'curl'/'socket' or false for auto-detect
50
  * @return Mage_HTTP_IClient
51
  */
52
  public static function getInstance($frontend = false)
53
  {
54
+ if (false === $frontend) {
 
55
  $frontend = self::detectFrontend();
56
  }
57
+ if (false === $frontend) {
 
58
  throw new Exception("Cannot find frontend automatically, set it manually");
59
  }
60
 
61
+ $class = __CLASS__ . "_" . str_replace(' ', DIRECTORY_SEPARATOR, ucwords(str_replace('_', ' ', $frontend)));
62
  $obj = new $class();
63
  return $obj;
64
  }
71
  */
72
  protected static function detectFrontend()
73
  {
74
+ if (function_exists("curl_init")) {
75
  return "curl";
76
  }
77
+ if (function_exists("fsockopen")) {
78
  return "socket";
79
  }
80
  return false;
downloader/lib/Mage/HTTP/Client/Curl.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_HTTP
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_HTTP
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/HTTP/Client/Socket.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_HTTP
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_HTTP
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/HTTP/IClient.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_HTTP
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_HTTP
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/System/Args.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_System
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
 
@@ -59,7 +59,7 @@ class Mage_System_Args
59
  {
60
  $this->flags = array();
61
  $this->filtered = array();
62
-
63
  if(false === $source) {
64
  $argv = $GLOBALS['argv'];
65
  array_shift($argv);
@@ -89,7 +89,7 @@ class Mage_System_Args
89
  }
90
  elseif(strlen($str) == 2 && $str[0] == '-') // -a
91
  {
92
- $this->flags[$str[1]] = true;
93
  if(isset($argv[$i + 1]) && preg_match('/^--?.+/', $argv[$i + 1]) == 0) {
94
  $this->flags[$str[1]] = $argv[$i + 1];
95
  $argv[$i + 1] = null;
20
  *
21
  * @category Mage
22
  * @package Mage_System
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
 
59
  {
60
  $this->flags = array();
61
  $this->filtered = array();
62
+
63
  if(false === $source) {
64
  $argv = $GLOBALS['argv'];
65
  array_shift($argv);
89
  }
90
  elseif(strlen($str) == 2 && $str[0] == '-') // -a
91
  {
92
+ $this->flags[$str[1]] = true;
93
  if(isset($argv[$i + 1]) && preg_match('/^--?.+/', $argv[$i + 1]) == 0) {
94
  $this->flags[$str[1]] = $argv[$i + 1];
95
  $argv[$i + 1] = null;
downloader/lib/Mage/System/Dirs.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_System
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
  class Mage_System_Dirs
@@ -35,12 +35,12 @@ class Mage_System_Dirs
35
  if (!@file_exists($dirname)) {
36
  return false;
37
  }
38
-
39
  // Simple delete for a file
40
  if (@is_file($dirname) || @is_link($dirname)) {
41
  return unlink($dirname);
42
  }
43
-
44
  // Create and iterate stack
45
  $stack = array($dirname);
46
  while ($entry = array_pop($stack)) {
@@ -49,12 +49,12 @@ class Mage_System_Dirs
49
  @unlink($entry);
50
  continue;
51
  }
52
-
53
  // Attempt to remove the directory
54
  if (@rmdir($entry)) {
55
  continue;
56
  }
57
-
58
  // Otherwise add it to the stack
59
  $stack[] = $entry;
60
  $dh = opendir($entry);
@@ -62,7 +62,7 @@ class Mage_System_Dirs
62
  // Ignore pointers
63
  if ($child === '.' || $child === '..') {
64
  continue;
65
- }
66
  // Unlink files and add directories to stack
67
  $child = $entry . DIRECTORY_SEPARATOR . $child;
68
  if (is_dir($child) && !is_link($child)) {
@@ -72,33 +72,33 @@ class Mage_System_Dirs
72
  }
73
  }
74
  @closedir($dh);
75
- }
76
  return true;
77
- }
78
-
79
-
80
  public static function mkdirStrict($path, $recursive = true, $mode = 0777)
81
  {
82
- $exists = file_exists($path);
83
  if($exists && is_dir($path)) {
84
  return true;
85
  }
86
  if($exists && !is_dir($path)) {
87
  throw new Exception("'{$path}' already exists, should be a dir, not a file!");
88
- }
89
- $out = @mkdir($path, $mode, $recursive);
90
  if(false === $out) {
91
  throw new Exception("Can't create dir: '{$path}'");
92
- }
93
  return true;
94
  }
95
-
96
  public static function copyFileStrict($source, $dest)
97
  {
98
  $exists = file_exists($source);
99
  if(!$exists) {
100
  throw new Exception('No file exists: '.$exists);
101
  }
102
-
103
  }
104
  }
20
  *
21
  * @category Mage
22
  * @package Mage_System
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
  class Mage_System_Dirs
35
  if (!@file_exists($dirname)) {
36
  return false;
37
  }
38
+
39
  // Simple delete for a file
40
  if (@is_file($dirname) || @is_link($dirname)) {
41
  return unlink($dirname);
42
  }
43
+
44
  // Create and iterate stack
45
  $stack = array($dirname);
46
  while ($entry = array_pop($stack)) {
49
  @unlink($entry);
50
  continue;
51
  }
52
+
53
  // Attempt to remove the directory
54
  if (@rmdir($entry)) {
55
  continue;
56
  }
57
+
58
  // Otherwise add it to the stack
59
  $stack[] = $entry;
60
  $dh = opendir($entry);
62
  // Ignore pointers
63
  if ($child === '.' || $child === '..') {
64
  continue;
65
+ }
66
  // Unlink files and add directories to stack
67
  $child = $entry . DIRECTORY_SEPARATOR . $child;
68
  if (is_dir($child) && !is_link($child)) {
72
  }
73
  }
74
  @closedir($dh);
75
+ }
76
  return true;
77
+ }
78
+
79
+
80
  public static function mkdirStrict($path, $recursive = true, $mode = 0777)
81
  {
82
+ $exists = file_exists($path);
83
  if($exists && is_dir($path)) {
84
  return true;
85
  }
86
  if($exists && !is_dir($path)) {
87
  throw new Exception("'{$path}' already exists, should be a dir, not a file!");
88
+ }
89
+ $out = @mkdir($path, $mode, $recursive);
90
  if(false === $out) {
91
  throw new Exception("Can't create dir: '{$path}'");
92
+ }
93
  return true;
94
  }
95
+
96
  public static function copyFileStrict($source, $dest)
97
  {
98
  $exists = file_exists($source);
99
  if(!$exists) {
100
  throw new Exception('No file exists: '.$exists);
101
  }
102
+
103
  }
104
  }
downloader/lib/Mage/System/Ftp.php ADDED
@@ -0,0 +1,509 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_System
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
+ * Class to work with remote FTP server
29
+ *
30
+ * @category Mage
31
+ * @package Mage_System
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_System_Ftp
35
+ {
36
+
37
+ /**
38
+ * Connection object
39
+ *
40
+ * @var resource
41
+ */
42
+ protected $_conn = false;
43
+
44
+ /**
45
+ * Check connected, throw exception if not
46
+ *
47
+ * @throws Exception
48
+ * @return void
49
+ */
50
+ protected function checkConnected()
51
+ {
52
+ if(!$this->_conn) {
53
+ throw new Exception(__CLASS__." - no connection established with server");
54
+ }
55
+ }
56
+
57
+ /**
58
+ * ftp_mkdir wrapper
59
+ *
60
+ * @param sting $name
61
+ * @return unknown_type
62
+ */
63
+ public function mdkir($name)
64
+ {
65
+ $this->checkConnected();
66
+ return @ftp_mkdir($this->_conn, $name);
67
+ }
68
+
69
+ /**
70
+ * Make dir recursive
71
+ *
72
+ * @param string $path
73
+ * @param int $mode
74
+ * @return bool
75
+ */
76
+ public function mkdirRecursive($path, $mode = 0777)
77
+ {
78
+ $this->checkConnected();
79
+ $dir = explode("/", $path);
80
+ $path= "";
81
+ $ret = true;
82
+ for ($i=0; $i < count($dir); $i++) {
83
+ $path .= "/" .$dir[$i];
84
+ if(!@ftp_chdir($this->_conn, $path)) {
85
+ @ftp_chdir($this->_conn,"/");
86
+ if(!@ftp_mkdir($this->_conn,$path)) {
87
+ $ret=false;
88
+ break;
89
+ } else {
90
+ @ftp_chmod($this->_conn, $mode, $path);
91
+ }
92
+ }
93
+ }
94
+ return $ret;
95
+ }
96
+
97
+ /**
98
+ * Try to login to server
99
+ *
100
+ * @param string $login
101
+ * @param string $password
102
+ * @throws Exception on invalid login credentials
103
+ * @return bool
104
+ */
105
+ public function login($login = "anonymous", $password = "")
106
+ {
107
+ $this->checkConnected();
108
+ $res = @ftp_login($this->_conn, $login, $password);
109
+ if(!$res) {
110
+ throw new Exception("Invalid login credentials");
111
+ }
112
+ return $res;
113
+ }
114
+
115
+ /**
116
+ * Validate connection string
117
+ *
118
+ * @param string $string
119
+ * @throws Exception
120
+ * @return string
121
+ */
122
+ public function validateConnectionString($string)
123
+ {
124
+ $data = @parse_url($string);
125
+ if(false === $data) {
126
+ throw new Exception("Connection string invalid: '{$string}'");
127
+ }
128
+ if($data['scheme'] != 'ftp') {
129
+ throw new Exception("Support for scheme unsupported: '{$data['scheme']}'");
130
+ }
131
+ return $data;
132
+ }
133
+
134
+ /**
135
+ * Connect to server using connect string
136
+ * Connection string: ftp://user:pass@server:port/path
137
+ * user,pass,port,path are optional parts
138
+ *
139
+ * @param string $string
140
+ * @param int $timeout
141
+ */
142
+ public function connect($string, $timeout = 900)
143
+ {
144
+ $params = $this->validateConnectionString($string);
145
+ $port = isset($params['port']) ? intval($params['port']) : 21;
146
+
147
+ $this->_conn = ftp_connect($params['host'], $port, $timeout);
148
+
149
+ if(!$this->_conn) {
150
+ throw new Exception("Cannot connect to host: {$params['host']}");
151
+ }
152
+ if(isset($params['user']) && isset($params['pass'])) {
153
+ $this->login($params['user'], $params['pass']);
154
+ } else {
155
+ $this->login();
156
+ }
157
+ if(isset($params['path'])) {
158
+ if(!$this->chdir($params['path'])) {
159
+ throw new Exception ("Cannot chdir after login to: {$params['path']}");
160
+ }
161
+ }
162
+ }
163
+
164
+ /**
165
+ * ftp_fput wrapper
166
+ *
167
+ * @param string $remoteFile
168
+ * @param resource $handle
169
+ * @param int $mode FTP_BINARY | FTP_ASCII
170
+ * @param int $startPos
171
+ * @return bool
172
+ */
173
+ public function fput($remoteFile, $handle, $mode = FTP_BINARY, $startPos = 0)
174
+ {
175
+ $this->checkConnected();
176
+ return @ftp_fput($this->_conn, $remoteFile, $handle, $mode, $startPos);
177
+ }
178
+
179
+ /**
180
+ * ftp_put wrapper
181
+ *
182
+ * @param string $remoteFile
183
+ * @param string $localFile
184
+ * @param int $mode FTP_BINARY | FTP_ASCII
185
+ * @param int $startPos
186
+ * @return bool
187
+ */
188
+ public function put($remoteFile, $localFile, $mode = FTP_BINARY, $startPos = 0)
189
+ {
190
+ $this->checkConnected();
191
+ return ftp_put($this->_conn, $remoteFile, $localFile, $mode, $startPos);
192
+ }
193
+
194
+ /**
195
+ * Get current working directory
196
+ *
197
+ * @return mixed
198
+ */
199
+ public function getcwd()
200
+ {
201
+ $d = $this->raw("pwd");
202
+ $data = explode(" ", $d[0], 3);
203
+ if(empty($data[1])) {
204
+ return false;
205
+ }
206
+ if(intval($data[0]) != 257) {
207
+ return false;
208
+ }
209
+ $out = trim($data[1], '"');
210
+ if($out !== "/") {
211
+ $out = rtrim($out, "/");
212
+ }
213
+ return $out;
214
+ }
215
+
216
+ /**
217
+ * ftp_raw wrapper
218
+ *
219
+ * @param string $cmd
220
+ * @return mixed
221
+ */
222
+ public function raw($cmd)
223
+ {
224
+ $this->checkConnected();
225
+ return @ftp_raw($this->_conn, $cmd);
226
+ }
227
+
228
+ /**
229
+ * Upload local file to remote
230
+ *
231
+ * Can be used for relative and absoulte remote paths
232
+ * Relative: use chdir before calling this
233
+ *
234
+ * @param srting $remote
235
+ * @param string $local
236
+ * @param int $dirMode
237
+ * @param int $ftpMode
238
+ * @return unknown_type
239
+ */
240
+ public function upload($remote, $local, $dirMode = 0777, $ftpMode = FTP_BINARY)
241
+ {
242
+ $this->checkConnected();
243
+
244
+ if(!file_exists($local)) {
245
+ throw new Exception("Local file doesn't exist: {$localFile}");
246
+ }
247
+ if(!is_readable($local)) {
248
+ throw new Exception("Local file is not readable: {$localFile}");
249
+ }
250
+ if(is_dir($local)) {
251
+ throw new Exception("Directory given instead of file: {$localFile}");
252
+ }
253
+
254
+ $globalPathMode = substr($remote, 0, 1) == "/";
255
+ $dirname = dirname($remote);
256
+ $cwd = $this->getcwd();
257
+ if(false === $cwd) {
258
+ throw new Exception("Server returns something awful on PWD command");
259
+ }
260
+
261
+ if(!$globalPathMode) {
262
+ $dirname = $cwd."/".$dirname;
263
+ $remote = $cwd."/".$remote;
264
+ }
265
+ $res = $this->mkdirRecursive($dirname, $dirMode);
266
+ $this->chdir($cwd);
267
+
268
+ if(!$res) {
269
+ return false;
270
+ }
271
+ return $this->put($remote, $local, $ftpMode);
272
+ }
273
+
274
+ /**
275
+ * Download remote file to local machine
276
+ *
277
+ * @param string $remote
278
+ * @param string $local
279
+ * @param int $ftpMode FTP_BINARY|FTP_ASCII
280
+ * @return bool
281
+ */
282
+ public function download($remote, $local, $ftpMode = FTP_BINARY)
283
+ {
284
+ $this->checkConnected();
285
+ return $this->get($local, $remote, $ftpMode);
286
+ }
287
+
288
+ /**
289
+ * ftp_pasv wrapper
290
+ *
291
+ * @param bool $pasv
292
+ * @return bool
293
+ */
294
+ public function pasv($pasv)
295
+ {
296
+ $this->checkConnected();
297
+ return @ftp_pasv($this->_conn, (bool) $pasv);
298
+ }
299
+
300
+ /**
301
+ * Close FTP connection
302
+ *
303
+ * @return void
304
+ */
305
+ public function close()
306
+ {
307
+ if($this->_conn) {
308
+ @ftp_close($this->_conn);
309
+ }
310
+ }
311
+
312
+ /**
313
+ * ftp_chmod wrapper
314
+ *
315
+ * @param $mode
316
+ * @param $remoteFile
317
+ * @return bool
318
+ */
319
+ public function chmod($mode, $remoteFile)
320
+ {
321
+ $this->checkConnected();
322
+ return @ftp_chmod($this->_conn, $mode, $remoteFile);
323
+ }
324
+
325
+ /**
326
+ * ftp_chdir wrapper
327
+ *
328
+ * @param string $dir
329
+ * @return bool
330
+ */
331
+ public function chdir($dir)
332
+ {
333
+ $this->checkConnected();
334
+ return @ftp_chdir($this->_conn, $dir);
335
+ }
336
+
337
+ /**
338
+ * ftp_cdup wrapper
339
+ *
340
+ * @return bool
341
+ */
342
+ public function cdup()
343
+ {
344
+ $this->checkConnected();
345
+ return @ftp_cdup($this->_conn);
346
+ }
347
+
348
+ /**
349
+ * ftp_get wrapper
350
+ *
351
+ * @param string $localFile
352
+ * @param string $remoteFile
353
+ * @param int $fileMode FTP_BINARY | FTP_ASCII
354
+ * @param int $resumeOffset
355
+ * @return bool
356
+ */
357
+ public function get($localFile, $remoteFile, $fileMode = FTP_BINARY, $resumeOffset = 0)
358
+ {
359
+ $remoteFile = $this->correctFilePath($remoteFile);
360
+ $this->checkConnected();
361
+ return @ftp_get($this->_conn, $localFile, $remoteFile, $fileMode, $resumeOffset);
362
+ }
363
+
364
+ /**
365
+ * ftp_nlist wrapper
366
+ *
367
+ * @param string $dir
368
+ * @return bool
369
+ */
370
+ public function nlist($dir = "/")
371
+ {
372
+ $this->checkConnected();
373
+ $dir = $this->correctFilePath($dir);
374
+ return @ftp_nlist($this->_conn, $dir);
375
+ }
376
+
377
+ /**
378
+ * ftp_rawlist wrapper
379
+ *
380
+ * @param string $dir
381
+ * @param bool $recursive
382
+ * @return mixed
383
+ */
384
+ public function rawlist( $dir = "/", $recursive = false )
385
+ {
386
+ $this->checkConnected();
387
+ $dir = $this->correctFilePath($dir);
388
+ return @ftp_rawlist($this->_conn, $dir, $recursive);
389
+ }
390
+
391
+ /**
392
+ * Convert byte count to float KB/MB format
393
+ *
394
+ * @param int $bytes
395
+ * @return string
396
+ */
397
+ public static function byteconvert($bytes)
398
+ {
399
+ $symbol = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
400
+ $exp = floor( log($bytes) / log(1024) );
401
+ return sprintf( '%.2f ' . $symbol[ $exp ], ($bytes / pow(1024, floor($exp))) );
402
+ }
403
+
404
+ /**
405
+ * Chmod string "-rwxrwxrwx" to "777" converter
406
+ *
407
+ * @param string $chmod
408
+ * @return string
409
+ */
410
+ public static function chmodnum($chmod)
411
+ {
412
+ $trans = array('-' => '0', 'r' => '4', 'w' => '2', 'x' => '1');
413
+ $chmod = substr(strtr($chmod, $trans), 1);
414
+ $array = str_split($chmod, 3);
415
+ return array_sum(str_split($array[0])) . array_sum(str_split($array[1])) . array_sum(str_split($array[2]));
416
+ }
417
+
418
+ /**
419
+ * Check whether file exists
420
+ *
421
+ * @param string $path
422
+ * @param bool $excludeIfIsDir
423
+ * @return bool
424
+ */
425
+ public function fileExists($path, $excludeIfIsDir = true)
426
+ {
427
+ $path = $this->correctFilePath($path);
428
+ $globalPathMode = substr($path, 0, 1) == "/";
429
+
430
+ $file = basename($path);
431
+ $dir = $globalPathMode ? dirname($path) : $this->getcwd()."/".$path;
432
+ $data = $this->ls($dir);
433
+ foreach($data as $row) {
434
+ if($file == $row['name']) {
435
+ if($excludeIfIsDir && $row['dir']) {
436
+ continue;
437
+ }
438
+ return true;
439
+ }
440
+ }
441
+ return false;
442
+ }
443
+
444
+ /**
445
+ * Get directory contents in PHP array
446
+ *
447
+ * @param string $dir
448
+ * @param bool $recursive
449
+ * @return array
450
+ */
451
+ public function ls($dir = "/", $recursive = false)
452
+ {
453
+ $dir= $this->correctFilePath($dir);
454
+ $rawfiles = (array) $this->rawlist($dir, $recursive);
455
+ $structure = array();
456
+ $arraypointer = &$structure;
457
+ foreach ($rawfiles as $rawfile) {
458
+ if ($rawfile[0] == '/') {
459
+ $paths = array_slice(explode('/', str_replace(':', '', $rawfile)), 1);
460
+ $arraypointer = &$structure;
461
+ foreach ($paths as $path) {
462
+ foreach ($arraypointer as $i => $file) {
463
+ if ($file['name'] == $path) {
464
+ $arraypointer = &$arraypointer[ $i ]['children'];
465
+ break;
466
+ }
467
+ }
468
+ }
469
+ } elseif(!empty($rawfile)) {
470
+ $info = preg_split("/[\s]+/", $rawfile, 9);
471
+ $arraypointer[] = array(
472
+ 'name' => $info[8],
473
+ 'dir' => $info[0]{0} == 'd',
474
+ 'size' => (int) $info[4],
475
+ 'chmod' => self::chmodnum($info[0]),
476
+ 'rawdata' => $info,
477
+ 'raw' => $rawfile
478
+ );
479
+ }
480
+ }
481
+ return $structure;
482
+ }
483
+
484
+ /**
485
+ * Correct file path
486
+ *
487
+ * @param string $str
488
+ * @return string
489
+ */
490
+ public function correctFilePath($str)
491
+ {
492
+ $str = str_replace("\\", "/", $str);
493
+ $str = preg_replace("/^.\//", "", $str);
494
+ return $str;
495
+ }
496
+
497
+ /**
498
+ * Delete file
499
+ *
500
+ * @param string $file
501
+ * @return bool
502
+ */
503
+ public function delete($file)
504
+ {
505
+ $this->checkConnected();
506
+ $file = $this->correctFilePath($file);
507
+ return @ftp_delete($this->_conn, $file);
508
+ }
509
+ }
downloader/lib/Mage/Xml/Generator.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_Xml
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
  class Mage_Xml_Generator
20
  *
21
  * @category Mage
22
  * @package Mage_Xml
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
  class Mage_Xml_Generator
downloader/lib/Mage/Xml/Parser.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Mage
22
  * @package Mage_Xml
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
  class Mage_Xml_Parser
20
  *
21
  * @category Mage
22
  * @package Mage_Xml
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
  class Mage_Xml_Parser
downloader/mage.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/skin/boxes.css CHANGED
@@ -19,7 +19,7 @@
19
  *
20
  * @category design
21
  * @package default
22
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
23
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
24
  */
25
  /*
19
  *
20
  * @category design
21
  * @package default
22
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
23
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
24
  */
25
  /*
downloader/skin/ie7boxes.css CHANGED
@@ -19,7 +19,7 @@
19
  *
20
  * @category design
21
  * @package default
22
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
23
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
24
  */
25
  .main { height:auto !important; }
19
  *
20
  * @category design
21
  * @package default
22
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
23
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
24
  */
25
  .main { height:auto !important; }
downloader/skin/ieboxes.css CHANGED
@@ -19,7 +19,7 @@
19
  *
20
  * @category design
21
  * @package default
22
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
23
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
24
  */
25
  button, .form-button { filter:chroma(color=#000000); overflow:visible; width:auto; }
19
  *
20
  * @category design
21
  * @package default
22
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
23
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
24
  */
25
  button, .form-button { filter:chroma(color=#000000); overflow:visible; width:auto; }
downloader/skin/install/boxes.css CHANGED
@@ -19,7 +19,7 @@
19
  *
20
  * @category design
21
  * @package default
22
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
23
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
24
  */
25
 
19
  *
20
  * @category design
21
  * @package default
22
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
23
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
24
  */
25
 
downloader/skin/install/clears.css CHANGED
@@ -19,7 +19,7 @@
19
  *
20
  * @category design
21
  * @package default
22
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
23
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
24
  */
25
 
19
  *
20
  * @category design
21
  * @package default
22
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
23
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
24
  */
25
 
downloader/skin/install/ie7minus.css CHANGED
@@ -19,7 +19,7 @@
19
  *
20
  * @category design
21
  * @package default
22
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
23
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
24
  */
25
 
19
  *
20
  * @category design
21
  * @package default
22
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
23
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
24
  */
25
 
downloader/skin/install/iestyles.css CHANGED
@@ -19,7 +19,7 @@
19
  *
20
  * @category design
21
  * @package default
22
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
23
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
24
  */
25
  .col2-set,
19
  *
20
  * @category design
21
  * @package default
22
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
23
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
24
  */
25
  .col2-set,
downloader/skin/install/reset.css CHANGED
@@ -19,7 +19,7 @@
19
  *
20
  * @category design
21
  * @package default
22
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
23
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
24
  */
25
  /******************************************/
19
  *
20
  * @category design
21
  * @package default
22
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
23
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
24
  */
25
  /******************************************/
downloader/target.xml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <targets>
3
+ <target name="magelocal" label="Magento Local module file" uri="./app/code/local" />
4
+ <target name="magecommunity" label="Magento Community module file" uri="./app/code/community" />
5
+ <target name="magecore" label="Magento Core team module file" uri="./app/code/core" />
6
+ <target name="magedesign" label="Magento User Interface (layouts, templates)" uri="./app/design" />
7
+ <target name="mageetc" label="Magento Global Configuration" uri="./app/etc" />
8
+ <target name="magelib" label="Magento PHP Library file" uri="./lib" />
9
+ <target name="magelocale" label="Magento Locale language file" uri="./app/locale" />
10
+ <target name="magemedia" label="Magento Media library" uri="./media" />
11
+ <target name="mageskin" label="Magento Theme Skin (Images, CSS, JS)" uri="./skin" />
12
+ <target name="mageweb" label="Magento Other web accessible file" uri="." />
13
+ <target name="magetest" label="Magento PHPUnit test" uri="./tests" />
14
+ <target name="mage" label="Magento other" uri="." />
15
+ </targets>
downloader/template/connect/iframe.phtml CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category design
22
  * @package default
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
@@ -51,7 +51,11 @@ function confirmExit()
51
 
52
  function onSubmit(formObj)
53
  {
54
- if(formObj)formObj.action = addParamToUrl(formObj.action, 'maintenance', (top.$('maintenance').checked === true ? '1' : '0'));
 
 
 
 
55
  top.$('connect_iframe_success').style.display = 'none';
56
  top.$('connect_iframe_failure').style.display = 'none';
57
  top.$('connect_iframe_container').style.display = '';
20
  *
21
  * @category design
22
  * @package default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
51
 
52
  function onSubmit(formObj)
53
  {
54
+ if(formObj){
55
+ formObj.action = addParamToUrl(formObj.action, 'maintenance', (top.$('maintenance').checked === true ? '1' : '0'));
56
+ formObj.action = addParamToUrl(formObj.action, 'archive_type', top.$('is_backup').checked === true ? top.$('archive_type').value:0);
57
+ formObj.action = addParamToUrl(formObj.action, 'backup_name', top.$('backup_name').value);
58
+ }
59
  top.$('connect_iframe_success').style.display = 'none';
60
  top.$('connect_iframe_failure').style.display = 'none';
61
  top.$('connect_iframe_container').style.display = '';
downloader/template/connect/packages.phtml CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category design
22
  * @package default
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
@@ -30,17 +30,59 @@
30
  <h4>Settings</h4>
31
  </div>
32
  <ul class="bare-list">
33
- <li><input type="checkbox" id="maintenance" value="1" checked="checked" /> &nbsp;
34
- <label for="maintenance">Put store on the maintenance mode while installing/upgrading</label>
35
- </li>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  </ul>
37
-
38
  <div class="bar-head">
39
  <h4>Install New Extensions</h4>
40
  </div>
41
  <script type="text/javascript">
42
  <!--
43
- function connectPrepare(form) {
 
 
 
 
 
 
 
 
 
44
  new Ajax.Request(form.action, {
45
  method:'post',
46
  parameters: {install_package_id: form.install_package_id.value},
20
  *
21
  * @category design
22
  * @package default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
30
  <h4>Settings</h4>
31
  </div>
32
  <ul class="bare-list">
33
+ <li>
34
+ <input type="checkbox" id="maintenance" value="1" checked="checked" /> &nbsp;
35
+ <label for="maintenance">Put store on the maintenance mode while installing/upgrading/backup creation</label>
36
+ </li>
37
+ <li>
38
+ <table cellpadding="0" cellspacing="0">
39
+ <tr>
40
+ <td rowspan="2" valign="top">
41
+ <input type="checkbox" id="is_backup" value="1" /> &nbsp;
42
+ </td>
43
+ <td>
44
+ <label for="is_backup">Create Backup</label>
45
+ </td>
46
+ <td>
47
+ &nbsp;<select id="archive_type" style="width: 320px;">
48
+ <option value="1">Database</option>
49
+ <option value="4">Database and Media</option>
50
+ <option value="2">System</option>
51
+ <option value="3">System (excluding Media)</option>
52
+ </select>
53
+ </td>
54
+ </tr>
55
+ <tr id="backup-name-container" style="display: none; margin-top: 5px;">
56
+ <td valign="top">
57
+ <div style="margin: 6px 0 0 5px;">
58
+ <label for="backup_name">Backup Name</label>
59
+ </div>
60
+ </td>
61
+ <td>
62
+ <div style="margin: 6px 0 0 4px;">
63
+ <input type="text" name="backup_name" id="backup_name" style="width: 318px;" maxlength="50"/>
64
+ <div class="notice-msg">Please use only letters (a-z or A-Z), numbers (0-9) or<br/> space in this field. Other characters are not allowed.</div>
65
+ </div>
66
+ </td>
67
+ </tr>
68
+ </table>
69
+ </li>
70
  </ul>
 
71
  <div class="bar-head">
72
  <h4>Install New Extensions</h4>
73
  </div>
74
  <script type="text/javascript">
75
  <!--
76
+ changeAvailableArchiveStatus = function (){
77
+ $('archive_type').disabled = !$('is_backup').checked;
78
+ $('is_backup').checked ? $('backup-name-container').show() : $('backup-name-container').hide();
79
+ $('backup_name').value = '';
80
+ }
81
+
82
+ Event.observe('is_backup', 'change', changeAvailableArchiveStatus);
83
+ Event.observe(window, 'load', changeAvailableArchiveStatus);
84
+
85
+ function connectPrepare(form) {
86
  new Ajax.Request(form.action, {
87
  method:'post',
88
  parameters: {install_package_id: form.install_package_id.value},
downloader/template/connect/packages_prepare.phtml CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category design
22
  * @package default
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
20
  *
21
  * @category design
22
  * @package default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
downloader/template/exception.phtml CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category design
22
  * @package default
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
20
  *
21
  * @category design
22
  * @package default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
downloader/template/footer.phtml CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category design
22
  * @package default
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
@@ -33,7 +33,7 @@
33
  <script type="text/javascript">
34
  $('bug_tracking_link').target = "varien_external";
35
  </script>
36
- Magento is a trademark of Magento, Inc. Copyright © 2010 Magento Inc.
37
  </p>
38
  </div>
39
  </body>
20
  *
21
  * @category design
22
  * @package default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
33
  <script type="text/javascript">
34
  $('bug_tracking_link').target = "varien_external";
35
  </script>
36
+ Magento is a trademark of Magento, Inc. Copyright &copy; 2012 Magento Inc.
37
  </p>
38
  </div>
39
  </body>
downloader/template/header.phtml CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category design
22
  * @package default
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
20
  *
21
  * @category design
22
  * @package default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
downloader/template/index.phtml CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category design
22
  * @package default
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
20
  *
21
  * @category design
22
  * @package default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
downloader/template/install/download.phtml CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category design
22
  * @package default
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
@@ -41,13 +41,13 @@
41
  <button class="form-button" type="button" onclick="location.href='<?php echo $this->mageUrl() ?>'"><span>Continue Magento installation</span></button>
42
  <br/><br/><br/>
43
  <p>Alternatively, you could proceed with Re-Downloading all packages</p>
44
- <?php echo($this->get('channel_notice')); ?>
45
  <form id="reinstall_all" method="post" action="<?php echo $this->url('connectInstallAll') ?>&force=1" target="connect_iframe" onsubmit="return installAll(true)">
46
  <fieldset class="fieldset-download">
47
  <?php endif; ?>
48
 
49
  <table cellspacing="0" class="form-list">
50
- <tr>
51
  <td class="label">Magento Connect Channel Protocol:</td>
52
  <td class="value">
53
  <select id="protocol" name="protocol">
@@ -55,8 +55,18 @@
55
  <option value="ftp" <?php if ($this->get('protocol')=='ftp'):?>selected="selected"<?php endif ?>>Ftp</option>
56
  </select>
57
  </td>
58
- </tr>
59
- <?php echo($this->get('channel_protocol_fields')); ?>
 
 
 
 
 
 
 
 
 
 
60
  <tr>
61
  <td class="label">Use Custom Permissions:</td>
62
  <td class="value">
@@ -71,13 +81,13 @@
71
  <tr>
72
  <td class="label">Folders:</td>
73
  <td class="value">
74
- <input id="mkdir_mode" name="mkdir_mode" value="<?php echo($this->get('mkdir_mode'));?>" type="text" class="input-text"></input>
75
  </td>
76
  </tr>
77
  <tr>
78
  <td class="label">Files:</td>
79
  <td class="value">
80
- <input id="chmod_file_mode" name="chmod_file_mode" value="<?php echo($this->get('chmod_file_mode'));?>" type="text" class="input-text"></input>
81
  </td>
82
  </tr>
83
  </table>
20
  *
21
  * @category design
22
  * @package default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
41
  <button class="form-button" type="button" onclick="location.href='<?php echo $this->mageUrl() ?>'"><span>Continue Magento installation</span></button>
42
  <br/><br/><br/>
43
  <p>Alternatively, you could proceed with Re-Downloading all packages</p>
44
+ <?php echo($this->get('channel_notice')); ?>
45
  <form id="reinstall_all" method="post" action="<?php echo $this->url('connectInstallAll') ?>&force=1" target="connect_iframe" onsubmit="return installAll(true)">
46
  <fieldset class="fieldset-download">
47
  <?php endif; ?>
48
 
49
  <table cellspacing="0" class="form-list">
50
+ <tr>
51
  <td class="label">Magento Connect Channel Protocol:</td>
52
  <td class="value">
53
  <select id="protocol" name="protocol">
55
  <option value="ftp" <?php if ($this->get('protocol')=='ftp'):?>selected="selected"<?php endif ?>>Ftp</option>
56
  </select>
57
  </td>
58
+ </tr>
59
+ <?php echo($this->get('channel_protocol_fields')); ?>
60
+ <tr>
61
+ <td class="label">Magento Version Stability:</td>
62
+ <td class="value">
63
+ <select id="preferred_state" name="preferred_state">
64
+ <option value="stable" <?php if ($this->get('preferred_state') == 'stable'):?>selected="selected"<?php endif ?>>stable</option>
65
+ <option value="beta" <?php if ($this->get('preferred_state') == 'beta'):?>selected="selected"<?php endif ?>>beta</option>
66
+ <option value="alpha" <?php if ($this->get('preferred_state') == 'alpha'):?>selected="selected"<?php endif ?>>alpha</option>
67
+ </select>
68
+ </td>
69
+ </tr>
70
  <tr>
71
  <td class="label">Use Custom Permissions:</td>
72
  <td class="value">
81
  <tr>
82
  <td class="label">Folders:</td>
83
  <td class="value">
84
+ <input id="mkdir_mode" name="mkdir_mode" value="<?php echo($this->get('mkdir_mode'));?>" type="text" class="input-text"/>
85
  </td>
86
  </tr>
87
  <tr>
88
  <td class="label">Files:</td>
89
  <td class="value">
90
+ <input id="chmod_file_mode" name="chmod_file_mode" value="<?php echo($this->get('chmod_file_mode'));?>" type="text" class="input-text"/>
91
  </td>
92
  </tr>
93
  </table>
downloader/template/install/footer.phtml CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category design
22
  * @package default
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
@@ -41,7 +41,7 @@
41
  <script type="text/javascript">
42
  $('bug_tracking_link').target = "varien_external";
43
  </script>
44
- Magento is a trademark of Magento, Inc. Copyright &copy; 2010 Magento Inc.</p>
45
  </div>
46
  </div>
47
  <!-- [end] footer -->
20
  *
21
  * @category design
22
  * @package default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
41
  <script type="text/javascript">
42
  $('bug_tracking_link').target = "varien_external";
43
  </script>
44
+ Magento is a trademark of Magento, Inc. Copyright &copy; 2012 Magento Inc.</p>
45
  </div>
46
  </div>
47
  <!-- [end] footer -->
downloader/template/install/header.phtml CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category design
22
  * @package default
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
20
  *
21
  * @category design
22
  * @package default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
downloader/template/install/writable.phtml CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category design
22
  * @package default
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
20
  *
21
  * @category design
22
  * @package default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
downloader/template/login.phtml CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category design
22
  * @package default
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
20
  *
21
  * @category design
22
  * @package default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
downloader/template/messages.phtml CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category design
22
  * @package default
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
20
  *
21
  * @category design
22
  * @package default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
downloader/template/noroute.phtml CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category design
22
  * @package default
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
20
  *
21
  * @category design
22
  * @package default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
downloader/template/settings.phtml CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category design
22
  * @package default
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
20
  *
21
  * @category design
22
  * @package default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
downloader/template/writable.phtml CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category design
22
  * @package default
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
20
  *
21
  * @category design
22
  * @package default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
index.php CHANGED
@@ -25,7 +25,12 @@
25
  */
26
 
27
  if (version_compare(phpversion(), '5.2.0', '<')===true) {
28
- echo '<div style="font:12px/1.35em arial, helvetica, sans-serif;"><div style="margin:0 0 25px 0; border-bottom:1px solid #ccc;"><h3 style="margin:0; font-size:1.7em; font-weight:normal; text-transform:none; text-align:left; color:#2f2f2f;">Whoops, it looks like you have an invalid PHP version.</h3></div><p>Magento supports PHP 5.2.0 or newer. <a href="http://www.magentocommerce.com/install" target="">Find out</a> how to install</a> Magento using PHP-CGI as a work-around.</p></div>';
 
 
 
 
 
29
  exit;
30
  }
31
 
@@ -37,12 +42,14 @@ error_reporting(E_ALL | E_STRICT);
37
  /**
38
  * Compilation includes configuration file
39
  */
40
- $compilerConfig = 'includes/config.php';
 
 
41
  if (file_exists($compilerConfig)) {
42
  include $compilerConfig;
43
  }
44
 
45
- $mageFilename = 'app/Mage.php';
46
  $maintenanceFile = 'maintenance.flag';
47
 
48
  if (!file_exists($mageFilename)) {
25
  */
26
 
27
  if (version_compare(phpversion(), '5.2.0', '<')===true) {
28
+ echo '<div style="font:12px/1.35em arial, helvetica, sans-serif;">
29
+ <div style="margin:0 0 25px 0; border-bottom:1px solid #ccc;">
30
+ <h3 style="margin:0; font-size:1.7em; font-weight:normal; text-transform:none; text-align:left; color:#2f2f2f;">
31
+ Whoops, it looks like you have an invalid PHP version.</h3></div><p>Magento supports PHP 5.2.0 or newer.
32
+ <a href="http://www.magentocommerce.com/install" target="">Find out</a> how to install</a>
33
+ Magento using PHP-CGI as a work-around.</p></div>';
34
  exit;
35
  }
36
 
42
  /**
43
  * Compilation includes configuration file
44
  */
45
+ define('MAGENTO_ROOT', getcwd());
46
+
47
+ $compilerConfig = MAGENTO_ROOT . '/includes/config.php';
48
  if (file_exists($compilerConfig)) {
49
  include $compilerConfig;
50
  }
51
 
52
+ $mageFilename = MAGENTO_ROOT . '/app/Mage.php';
53
  $maintenanceFile = 'maintenance.flag';
54
 
55
  if (!file_exists($mageFilename)) {
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Mage_Downloader</name>
4
- <version>1.6.2.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Magento Downloader</summary>
10
  <description>Magento Downloader</description>
11
- <notes>1.6.2.0</notes>
12
  <authors><author><name>Magento Core Team</name><user>core</user><email>core@magentocommerce.com</email></author></authors>
13
- <date>2012-01-11</date>
14
- <time>11:50:47</time>
15
- <contents><target name="mage"><dir name="downloader"><dir name="js"><file name="prototype.js" hash="3766aeff5778b54f74f93670322ca0df"/></dir><dir name="Maged"><dir name="Connect"><file name="Frontend.php" hash="e469328440d5d865db40ed6dec2eb0dd"/></dir><file name="Connect.php" hash="3878355516c34d9544a02d44a4c1e2b8"/><file name="Controller.php" hash="667cee056eef10004144cbadab05a299"/><file name="Exception.php" hash="31befe07df0a61598f063f543991a04b"/><dir name="Model"><dir name="Config"><file name="Abstract.php" hash="b87bd9947efce3f373ff65e0c997334e"/><file name="Community.php" hash="0e39f2375ec50ef5c8d7994e67eaf49e"/><file name="Interface.php" hash="fe6daef73f9f63adcce14dd322a41050"/></dir><file name="Config.php" hash="0fdf21421b2874620f4708b835ad34d5"/><dir name="Connect"><file name="Request.php" hash="9b89d6528986fcd5b97d59a8ceb48eac"/></dir><file name="Connect.php" hash="c63a751c9c720a3c8b670134b816c2aa"/><file name="Dowloader.php" hash="01885097ba694f6e0119f3eaecfa463f"/><file name="Session.php" hash="2876ecde6b2c2bba65e11c3dcf2d913f"/></dir><file name="Model.php" hash="9d43f384a202246af906c65e156d4aaa"/><file name="View.php" hash="38f23f08650249dcb75ff6a0e203ad28"/></dir><dir name="skin"><file name="boxes.css" hash="5a6a94b06fbd4335b4d0f78b94cb9712"/><file name="ie7boxes.css" hash="c9e684ca787f6521190922e7e2e6ed9e"/><file name="ieboxes.css" hash="ff95c4f8ade70c9178f1315eb61eaabe"/><dir name="images"><file name="Magento_Connect.jpg" hash="20e1378c09506fdc5723abc0115d5f57"/><file name="ajax-loader-tr.gif" hash="1ae32bc8232ff2527c627e5b38eb319a"/><file name="btn_bg.gif" hash="37c51a4d48a92da9648dcd3ca011039f"/><file name="header_bg.gif" hash="8440b04c5cb6b1451bb886bfbef260a5"/><file name="logo.gif" hash="5eb089ecea67d82311d7c91898460104"/><file name="nav_bg.gif" hash="1cb1366f03a9efad6b17e4483aef20cf"/><file name="nav_separator.gif" hash="492011a7de2de84a9c7837bfd879ab95"/></dir><dir name="install"><file name="boxes.css" hash="b6d074b3fce501813ed1d8dd323bf422"/><file name="clears.css" hash="bc94c9e4ee77d82530ca33b468b502e4"/><file name="ie7minus.css" hash="e0bad17242a3b6c20516bb292bf16493"/><file name="iestyles.css" hash="eb20094050695e0e02f0318b37c24e08"/><dir name="images"><file name="error_msg_icon.gif" hash="e4f28607f075a105e53fa3113d84bd26"/><file name="footer_bg.gif" hash="d59784af16fd95ea82226e5708a89232"/><file name="footer_container_bg.gif" hash="d468e3943943cbbf711586e69d40ca42"/><file name="footer_info_separator.gif" hash="7da64eefaf4da3855ab6ee76dbced0c2"/><file name="footer_informational_bg.gif" hash="72d37f4b2ea747bf8969c2654ad1d1e0"/><file name="footer_left.gif" hash="2b15a54bea9409a75c142d14a62f0149"/><file name="footer_legality_bg.gif" hash="4eb1602e3369dccd901ffe98ea0fd4b3"/><file name="footer_right.gif" hash="a45eaf35c8797d299bd4d9b936528e8f"/><file name="header_bg.gif" hash="795c6de754d0d49717ed08d5cd8168c8"/><file name="header_nav_bg.gif" hash="80c6a18686eb0243e06d6176506a2502"/><file name="header_top_bg.jpg" hash="143f524392ee62fcc8183f5930d7258b"/><file name="header_top_container_bg.jpg" hash="294c18f3f6b838bba06ae41dd3c3d638"/><file name="logo.gif" hash="073a947a39b967af678455a5c7f66e90"/><file name="main_bg.gif" hash="cf18ba9f7c7e6b058b439cde1a897e9c"/><file name="main_container_bg.gif" hash="a8f5717873dc6cf8f6bd22924b5838fe"/><file name="note_msg_icon.gif" hash="e774ee481a2820789c1a77112377c4e0"/><file name="success_msg_icon.gif" hash="834dfafd5f8b44c4b24a4c00add56fcf"/><file name="validation_advice_bg.gif" hash="b85432906de8985a8b14eeb2dc652d3c"/></dir><file name="reset.css" hash="f473723e7a0aff5d6feedbbab6cb3392"/></dir></dir><dir name="template"><dir name="connect"><file name="iframe.phtml" hash="2aa7c28d092c43e14b8b1fe413e6a126"/><file name="packages.phtml" hash="72c6024a9891c01b603f2766f52ff914"/><file name="packages_prepare.phtml" hash="bd34d2a794e5fcc84d4ea22b5754d250"/></dir><file name="exception.phtml" hash="ce8145052f0a730088fc849c04c58c64"/><file name="footer.phtml" hash="454299883c093cc98b4550c99bba03b9"/><file name="header.phtml" hash="73ab5e15a8a58d624fb5b8e48da679d3"/><file name="index.phtml" hash="1c7d5cbca5c16632db3f891024086947"/><dir name="install"><file name="download.phtml" hash="b7f283992b89cae9e85cc655e4b2d4e3"/><file name="footer.phtml" hash="6a70fd31200cb9bfddf65d7f8f67ac5e"/><file name="header.phtml" hash="f07d63df229468c28043869f0b71e194"/><file name="writable.phtml" hash="2815049a02b3f1110b9f22e22047b941"/></dir><file name="login.phtml" hash="ad91f8daa2d8a8974782350a2d2e2578"/><file name="messages.phtml" hash="8753c0c5599fa55a190c4913651b2c77"/><file name="noroute.phtml" hash="ad5ded291fcbf3899af4f499b77aaf42"/><file name="settings.phtml" hash="5bda5f6e749e288f7e2cb0fc2b7f1b83"/><file name="writable.phtml" hash="5fc31df4f9795e8febe39da1e59d91cd"/><file name=".htaccess" hash="72617d60821288133a367f70bf39ad93"/></dir><file name="index.php" hash="db1b840cef501ba7830d1035d6a3df7b"/><dir name="lib"><dir name="Mage"><dir name="Archive"><file name="Abstract.php" hash="a17be2772775eac2d1e3a36041a9f3c1"/><file name="Bz.php" hash="4e95c019f7c8983ecb225d0847806bed"/><file name="Gz.php" hash="e832e68bd2a3165234b6d6b52b3fcac0"/><file name="Interface.php" hash="1c57bd8e6ee7dbe4cfcaa3dfdceb1d7b"/><file name="Tar.php" hash="12983e34995349ab736eb8c5bbe03ba6"/></dir><file name="Archive.php" hash="7947ccf15f5df8300e7cf1a4681b9569"/><dir name="Autoload"><file name="Simple.php" hash="e062bd1b45f0b08ac456d3e0dc4c06b6"/></dir><dir name="Connect"><dir name="Channel"><file name="Generator.php" hash="4bbda17b29549ae9a50ea09c0db54649"/><file name="Parser.php" hash="3546e3b66eafe78bdd5628dc37f4bca9"/><file name="VO.php" hash="0525a71b043486aca9febcac6ce0ccff"/></dir><dir name="Command"><file name="Channels.php" hash="83e47fe8f407212ecc1797028211d15d"/><file name="Channels_Header.php" hash="8a828b219ec1b57eba88806845f133cb"/><file name="Config.php" hash="22161cf90d8d2abb5409a30dbe28a44c"/><file name="Config_Header.php" hash="0ce12f7207fe610f886aae15df145615"/><file name="Install.php" hash="b40177f31744db26010c8fbe8e10b05a"/><file name="Install_Header.php" hash="1d4da6660edb2e63ea9a223ccfe4610d"/><file name="Package.php" hash="09d265ec9666b7729276a54c88db1263"/><file name="Package_Header.php" hash="102080d8fad7234b60b103a5dbf65754"/><file name="Registry.php" hash="898b91578ee622b4914023edc9e34984"/><file name="Registry_Header.php" hash="fb37813d34f75835e4ecccea704b2ab0"/><file name="Remote.php" hash="3b0f8aa676ddd677e3a57823d8b0c60e"/><file name="Remote_Header.php" hash="9bd703a45c70ccc959f922392decc962"/></dir><file name="Command.php" hash="b3314fecd974fc3d767049cf323cc254"/><file name="Config.php" hash="4d688d01fd05522fa36166656bd5c697"/><file name="Converter.php" hash="435aad5d121240eb7784f3f71a848392"/><dir name="Frontend"><file name="CLI.php" hash="0b71bae7609966ebfcfc04f63a0318a3"/></dir><file name="Frontend.php" hash="811d665cee46fdbea623d651cf4ac44b"/><file name="Ftp.php" hash="4adbc5b56bf2be7ca7d042f78ae61298"/><dir name="Loader"><file name="Ftp.php" hash="1fbff02e85c5e2f7f0e61d8577c248d6"/></dir><file name="Loader.php" hash="ba5151383e4931a7f767a2d1897cb2a7"/><dir name="Package"><file name="Extension.php" hash="68b329da9893e34099c7d8ad5cb9c940"/><file name="Hotfix.php" hash="370177a5cf2f3397e0b341466d34de75"/><file name="Maintainer.php" hash="68b329da9893e34099c7d8ad5cb9c940"/><file name="Reader.php" hash="7fa1d41c6145f178e50e8a266e361f1e"/><file name="Target.php" hash="09c91f931b37f5e350a7ebdbb6bbf442"/><file name="VO.php" hash="e42f4d13abcaa766ca35f24c6280043b"/><file name="Writer.php" hash="32088dd140dfd14b3bde9c11a32b7d35"/></dir><file name="Package.php" hash="bcc3ed40ad75f37e6be0d90e833a84bb"/><file name="Packager.php" hash="2eb9fb87e4bf3d8a8a0a27d1b2c8994d"/><dir name="Repository"><file name="Abstract.php" hash="68b329da9893e34099c7d8ad5cb9c940"/><dir name="Channel"><file name="Abstract.php" hash="68b329da9893e34099c7d8ad5cb9c940"/><file name="Commercial.php" hash="68b329da9893e34099c7d8ad5cb9c940"/><file name="Community.php" hash="68b329da9893e34099c7d8ad5cb9c940"/><file name="Core.php" hash="68b329da9893e34099c7d8ad5cb9c940"/></dir><file name="Channel.php" hash="68b329da9893e34099c7d8ad5cb9c940"/><file name="Local.php" hash="68b329da9893e34099c7d8ad5cb9c940"/></dir><file name="Repository.php" hash="68b329da9893e34099c7d8ad5cb9c940"/><file name="Rest.php" hash="9bf931f43e0840f903ce9089d90779a2"/><file name="Singleconfig.php" hash="bdcb3dcfb2a58b290cce8da370f8ac9c"/><dir name="Structures"><file name="Graph.php" hash="bb484f7ed43d819d9964c3dfa0489641"/><file name="Node.php" hash="5fe101c2a3c371ebca23b1a77a4d8b9a"/></dir><file name="Validator.php" hash="500f1fec82dc873ef02fae0d738b5162"/></dir><dir name="DB"><file name="Exception.php" hash="38385d6b8ba6dfabf53aa275ca5b1086"/><file name="Mysqli.php" hash="7afa22548284f2e6e8796fce50f736ce"/></dir><file name="Exception.php" hash="a5e649c88e376f850b83d35900525a7f"/><dir name="HTTP"><dir name="Client"><file name="Curl.php" hash="8eba20650fc9da09d8585e31ea3bd053"/><file name="Socket.php" hash="a1b2788a4fa596f70430d309ffc8f59f"/></dir><file name="Client.php" hash="189e5288453ce792e1eacbb178e20fd1"/><file name="IClient.php" hash="eb44927eabc6a87fbf37d52643732b2d"/></dir><dir name="System"><file name="Args.php" hash="a3058a52f975e8436a8d2b113943489a"/><file name="Dirs.php" hash="0addfeb8f206cc67539ca0625921e016"/></dir><dir name="Xml"><file name="Generator.php" hash="c0b790125cc714d1ca43cfdc046768ed"/><file name="Parser.php" hash="6f8ac6fb3c6332c257d28e335909e855"/></dir></dir></dir><file name="config.ini" hash="a52ba98e71ab19de387b3af1a04c6102"/><file name=".htaccess" hash="520cc012c84739584526b8a9ff098e23"/><file name="mage.php" hash="6de4d106e8080bd2be838d1674bf6136"/></dir><dir name="."><file name=".htaccess" hash="8c1f49780253bb13b4fa89d604e814b6"/><file name="index.php" hash="20b1633bd332a08e643afa4590ab8564"/><file name="mage" hash="091c45355c62a9189cff45c09328037c"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Mage_Downloader</name>
4
+ <version>1.7.0.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Magento Downloader</summary>
10
  <description>Magento Downloader</description>
11
+ <notes>1.7.0.0</notes>
12
  <authors><author><name>Magento Core Team</name><user>core</user><email>core@magentocommerce.com</email></author></authors>
13
+ <date>2012-04-23</date>
14
+ <time>13:48:55</time>
15
+ <contents><target name="mage"><dir name="downloader"><dir name="js"><file name="prototype.js" hash="3766aeff5778b54f74f93670322ca0df"/></dir><dir name="Maged"><dir name="Connect"><file name="Frontend.php" hash="4fe09028f888fa69d757e70586926934"/></dir><file name="Connect.php" hash="4d38643a33b55d6619df9ee2c24c0eb6"/><file name="Controller.php" hash="e9e203482ecd973c2cc9710d7cdd5f24"/><file name="Exception.php" hash="6f67616c70457dedaf200514ed8f22eb"/><dir name="Model"><dir name="Config"><file name="Abstract.php" hash="a8b9ed4183feba4fce6dfdd6def98fe9"/><file name="Community.php" hash="b62d4b9351b03ed18814f577cdd0554e"/><file name="Interface.php" hash="4681957952bde0a7568579c28063f018"/></dir><file name="Config.php" hash="9bdd8870e781358c239d60cafe721474"/><dir name="Connect"><file name="Request.php" hash="f47d5504c23b710e3b112833f68e7d4a"/></dir><file name="Connect.php" hash="d859ee5c7d29a281f1ef0a73221aa83b"/><file name="Dowloader.php" hash="4db9eccccba5bc1dc37d306cf3c01c64"/><file name="Session.php" hash="f6e2df52f878281a73664de1573d14ea"/></dir><file name="Model.php" hash="1a3077e52a798abc65ede9db60c9d045"/><file name="View.php" hash="f0dfef91487a67b430076f34c9bd63aa"/></dir><dir name="skin"><file name="boxes.css" hash="33e04ab8ce0771675f186814ad40bc3f"/><file name="ie7boxes.css" hash="a0a4d69217dbf48d3863119f6cf3c212"/><file name="ieboxes.css" hash="7ca8f738ac7d942c94bf2ff1f7ab9521"/><dir name="images"><file name="Magento_Connect.jpg" hash="20e1378c09506fdc5723abc0115d5f57"/><file name="ajax-loader-tr.gif" hash="1ae32bc8232ff2527c627e5b38eb319a"/><file name="btn_bg.gif" hash="37c51a4d48a92da9648dcd3ca011039f"/><file name="header_bg.gif" hash="8440b04c5cb6b1451bb886bfbef260a5"/><file name="logo.gif" hash="5eb089ecea67d82311d7c91898460104"/><file name="nav_bg.gif" hash="1cb1366f03a9efad6b17e4483aef20cf"/><file name="nav_separator.gif" hash="492011a7de2de84a9c7837bfd879ab95"/></dir><dir name="install"><file name="boxes.css" hash="d72786129e3642090a25e69fa08fcbd2"/><file name="clears.css" hash="b5e5ed0fbb15056a4d72b35159738ee4"/><file name="ie7minus.css" hash="f42c22534c0442efcb75c1d25f9f0c1b"/><file name="iestyles.css" hash="2f88cf8316e56a514e9f0234b8e438f6"/><dir name="images"><file name="error_msg_icon.gif" hash="e4f28607f075a105e53fa3113d84bd26"/><file name="footer_bg.gif" hash="d59784af16fd95ea82226e5708a89232"/><file name="footer_container_bg.gif" hash="d468e3943943cbbf711586e69d40ca42"/><file name="footer_info_separator.gif" hash="7da64eefaf4da3855ab6ee76dbced0c2"/><file name="footer_informational_bg.gif" hash="72d37f4b2ea747bf8969c2654ad1d1e0"/><file name="footer_left.gif" hash="2b15a54bea9409a75c142d14a62f0149"/><file name="footer_legality_bg.gif" hash="4eb1602e3369dccd901ffe98ea0fd4b3"/><file name="footer_right.gif" hash="a45eaf35c8797d299bd4d9b936528e8f"/><file name="header_bg.gif" hash="795c6de754d0d49717ed08d5cd8168c8"/><file name="header_nav_bg.gif" hash="80c6a18686eb0243e06d6176506a2502"/><file name="header_top_bg.jpg" hash="143f524392ee62fcc8183f5930d7258b"/><file name="header_top_container_bg.jpg" hash="294c18f3f6b838bba06ae41dd3c3d638"/><file name="logo.gif" hash="073a947a39b967af678455a5c7f66e90"/><file name="main_bg.gif" hash="cf18ba9f7c7e6b058b439cde1a897e9c"/><file name="main_container_bg.gif" hash="a8f5717873dc6cf8f6bd22924b5838fe"/><file name="note_msg_icon.gif" hash="e774ee481a2820789c1a77112377c4e0"/><file name="success_msg_icon.gif" hash="834dfafd5f8b44c4b24a4c00add56fcf"/><file name="validation_advice_bg.gif" hash="b85432906de8985a8b14eeb2dc652d3c"/></dir><file name="reset.css" hash="88a8829ca099b8097c027b5171a18b9e"/></dir></dir><dir name="template"><dir name="connect"><file name="iframe.phtml" hash="feb0019f3b24f0ef22d559c5452bea93"/><file name="packages.phtml" hash="92ac198f0535e3026fbb7aed30ef900e"/><file name="packages_prepare.phtml" hash="cd95935a77fa40204fb3a6098be6ba6b"/></dir><file name="exception.phtml" hash="9112a87043f800452d4798f79104c42a"/><file name="footer.phtml" hash="2a4c95216d7f7f6385e317adf336b370"/><file name="header.phtml" hash="07647a5330dcb65fa3139953f533b6eb"/><file name="index.phtml" hash="f5e71e5949024e65f9658465cd670ff9"/><dir name="install"><file name="download.phtml" hash="b338372b3a810db50d04a56239efe6f9"/><file name="footer.phtml" hash="03e05ab4c0019af21ce04dc50adb6b30"/><file name="header.phtml" hash="86c59b34ff535813998251230008df2b"/><file name="writable.phtml" hash="bdabd54c935d8fa792c32a445785eec4"/></dir><file name="login.phtml" hash="00757361177ae096ce3e5d8c6bc9d2f5"/><file name="messages.phtml" hash="382dd9e57a0cb2ad40835faab731e78b"/><file name="noroute.phtml" hash="0a5d2c9f2edfd93aaf61872c057e861a"/><file name="settings.phtml" hash="a2428dcd6043ad12cd57b22522445edf"/><file name="writable.phtml" hash="ad326c80f9200acf9b384278ee02bd14"/><file name=".htaccess" hash="72617d60821288133a367f70bf39ad93"/></dir><file name="index.php" hash="59d0f4c9df534bafbc579b955b53c0d5"/><dir name="lib"><dir name="Mage"><dir name="Archive"><file name="Abstract.php" hash="b7f8bdc9763e854f7ad4d5b594c1ac15"/><file name="Bz.php" hash="1540dff33b3c6c7f35606a26c460c35c"/><file name="Gz.php" hash="58d726155821ba69b60b3e55f3b00626"/><dir name="Helper"><dir name="File"><file name="Bz.php" hash="b66762064e2f568387a1e46ebe3f73ec"/><file name="Gz.php" hash="04787ad51c00a6074098ac70a2157524"/></dir><file name="File.php" hash="e496754ff78f5d835f38668c749e5536"/></dir><file name="Interface.php" hash="2885cfb41142f3e175754142327b10a1"/><file name="Tar.php" hash="71c6e2807119ab246697d58298307a69"/></dir><file name="Archive.php" hash="89fd8fb3edf1717f2c470d6aec3d9a8a"/><dir name="Autoload"><file name="Simple.php" hash="edaca06790916fba7b67bdc4664de379"/></dir><dir name="Backup"><file name="Abstract.php" hash="b6bd3812291ccd668278784f7bdb7806"/><dir name="Archive"><file name="Tar.php" hash="429cae30f1889fa1d092a1c72e1270d3"/></dir><file name="Db.php" hash="cc335666483a450d270fc36216c9bb49"/><dir name="Exception"><file name="CantLoadSnapshot.php" hash="d30ac0555d45c148cca4408bd3495b0f"/><file name="FtpConnectionFailed.php" hash="707053159bdf14218dadaea1b9e13140"/><file name="FtpValidationFailed.php" hash="76c12d9de55c4993ff6cc01a852c5a62"/><file name="NotEnoughFreeSpace.php" hash="f37d646665fb452e069e6943a160e3f7"/><file name="NotEnoughPermissions.php" hash="e164152009802c81d1d9b16a7092a35a"/></dir><file name="Exception.php" hash="2d2c716daf5f40358198327e106e0fe8"/><dir name="Filesystem"><file name="Helper.php" hash="fea2db288f81cc5edd534500d544c94d"/><dir name="Iterator"><file name="File.php" hash="59d755c14d9acf6b6e50b9e188232864"/><file name="Filter.php" hash="bef925e4c9e5e53df1a1eed89d6fcde9"/></dir><dir name="Rollback"><file name="Abstract.php" hash="973e30e2524800e1629898db6804849a"/><file name="Fs.php" hash="6ebeb95156f7d923f708e824fcf16d85"/><file name="Ftp.php" hash="db46fe2b2f1d8c4f22fc7b5814571d54"/></dir></dir><file name="Filesystem.php" hash="afa266881fcaf0c8c949530749ec4395"/><file name="Interface.php" hash="ddcac17d1064747460d3991d17214206"/><file name="Media.php" hash="7da4db0f9f6a38240c5b94d02d87f02f"/><file name="Nomedia.php" hash="a052773007784001a291cf5a6477cd4e"/><file name="Snapshot.php" hash="96d1c723f8b514ccc2dbc0135518a23d"/></dir><file name="Backup.php" hash="446cc8a5a1be8b25fee8e428718d2539"/><dir name="Connect"><dir name="Channel"><file name="Generator.php" hash="10c6379b4e5d3fb6e1f4bf45636f3a7e"/><file name="Parser.php" hash="4ee4ae8127c2c237780efd7f8cd8e2d5"/><file name="VO.php" hash="25218657e5dac61a86da34d1ee939c72"/></dir><dir name="Command"><file name="Channels.php" hash="0664504015fe5adf16d7eac5fa8115b9"/><file name="Channels_Header.php" hash="da0175a83deb932b26a03f40e30f1f53"/><file name="Config.php" hash="b39ccf3580aa0e2eca4df41673284370"/><file name="Config_Header.php" hash="1e7f78746a0868e22fc5486a4418c1e5"/><file name="Install.php" hash="8cf37b3c4c74fb337b74a91dfdf95723"/><file name="Install_Header.php" hash="83baaa51a6a20c92b2361ba3bfdafbfc"/><file name="Package.php" hash="e21ba489a73e7fa2118b3232296fba80"/><file name="Package_Header.php" hash="aa42b4c57f9d502bbcb24fec227f415e"/><file name="Registry.php" hash="dd5094b28cf79bc974bcffbfeb5437aa"/><file name="Registry_Header.php" hash="b0ff5e62f3fdfa54ae1dd8d7a8715d9e"/><file name="Remote.php" hash="9656e8f84507a923eb78beaafacefb69"/><file name="Remote_Header.php" hash="4c4f749c1ce526dc167999ca6523e639"/></dir><file name="Command.php" hash="76e9d496c2f8f7cbecd4ff7a0ef4b52c"/><file name="Config.php" hash="1a8125efb52b91cd2f97d62153a711ba"/><file name="Converter.php" hash="4dd2ecdef9029ab83a63623210971493"/><dir name="Frontend"><file name="CLI.php" hash="5a08b39356328f2e71fca94780a9319c"/></dir><file name="Frontend.php" hash="dff73132ce54aa9e98319d2a727fbdef"/><file name="Ftp.php" hash="7479d8494f1a5ca39ff5d8738e715868"/><dir name="Loader"><file name="Ftp.php" hash="bb092c35e67160adc9e15033c9d44695"/></dir><file name="Loader.php" hash="737f0ae09d6a04ebe469ec55670246b5"/><dir name="Package"><file name="Extension.php" hash="68b329da9893e34099c7d8ad5cb9c940"/><file name="Hotfix.php" hash="176f0519dde3995db550c4fb29bb086f"/><file name="Maintainer.php" hash="68b329da9893e34099c7d8ad5cb9c940"/><file name="Reader.php" hash="7611f368c8d0615a3095ceaaea128c7b"/><file name="Target.php" hash="1515175e613053d99574d34ca246e22b"/><file name="VO.php" hash="1e77d1085c38a23bd32ec331481fdf03"/><file name="Writer.php" hash="d7ab1821e01bb4d63e44ec6ace10ff8e"/></dir><file name="Package.php" hash="8bdae55c54dd4e9b7ad303cce788908b"/><file name="Packager.php" hash="e3205a74535f84bd76be1f817e850c30"/><dir name="Repository"><file name="Abstract.php" hash="68b329da9893e34099c7d8ad5cb9c940"/><dir name="Channel"><file name="Abstract.php" hash="68b329da9893e34099c7d8ad5cb9c940"/><file name="Commercial.php" hash="68b329da9893e34099c7d8ad5cb9c940"/><file name="Community.php" hash="68b329da9893e34099c7d8ad5cb9c940"/><file name="Core.php" hash="68b329da9893e34099c7d8ad5cb9c940"/></dir><file name="Channel.php" hash="68b329da9893e34099c7d8ad5cb9c940"/><file name="Local.php" hash="68b329da9893e34099c7d8ad5cb9c940"/></dir><file name="Repository.php" hash="68b329da9893e34099c7d8ad5cb9c940"/><file name="Rest.php" hash="8e2edb3faecb5ebdd74acba3a67d7a15"/><file name="Singleconfig.php" hash="02e550061f3935ae81abf7007cf2836b"/><dir name="Structures"><file name="Graph.php" hash="50d44994ebe38bcb81eef2080c75c272"/><file name="Node.php" hash="a13945dbd6b324d2d6aaea5c884a6faf"/></dir><file name="Validator.php" hash="baad7be25698e4b1ae1ef0e6ae30ade7"/></dir><dir name="DB"><file name="Exception.php" hash="dba98805dd8b54890fe3481e238af6b5"/><file name="Mysqli.php" hash="0e459564416d054c612449f32973a12b"/></dir><file name="Exception.php" hash="a906d87346a42ce908b369ed9a815c0d"/><dir name="HTTP"><dir name="Client"><file name="Curl.php" hash="eac4cc44bccf3b1b864c0bb7756bef0a"/><file name="Socket.php" hash="0cd98c69664cf2ba4f6bcd47e63c754e"/></dir><file name="Client.php" hash="6c91a7f1f7aab44b97ca0165fda72cd5"/><file name="IClient.php" hash="d9d65816841655537b23135f9d24998f"/></dir><dir name="System"><file name="Args.php" hash="294fde4aee01ad3863f7ac6ffa28aa51"/><file name="Dirs.php" hash="96c581cfae7afcbb92e57c249dfbc09f"/><file name="Ftp.php" hash="6199bf4c4b2290a706e8f8ed77c5e4cb"/></dir><dir name="Xml"><file name="Generator.php" hash="db962d256d018a61ce76af6967eee155"/><file name="Parser.php" hash="6ee6c11c18da4005521b5cbc3dc5f9c8"/></dir></dir></dir><file name="config.ini" hash="a52ba98e71ab19de387b3af1a04c6102"/><file name=".htaccess" hash="520cc012c84739584526b8a9ff098e23"/><file name="mage.php" hash="68ff3a69caadee17b5b772c7cb6349ee"/><file name="favicon.ico" hash="88733ee53676a47fc354a61c32516e82"/><file name="target.xml" hash="50d1653dcdd94bcc01899c9dacaceeb1"/></dir><dir name="."><file name=".htaccess" hash="7d69e28ca7c422e6de19ff51bb23dab1"/><file name="index.php" hash="73d62a354e51517afd247faa731f8ad3"/><file name="mage" hash="091c45355c62a9189cff45c09328037c"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>