@@ -36,8 +36,7 @@ class PluginCompression extends AJXP_Plugin
36
36
*/
37
37
public function receiveAction ($ action , $ httpVars , $ fileVars )
38
38
{
39
- //TODO : DESTROY THE PROGRESS FILE AT THE END OF THE PROCESS + POSSIBILITY TO CANCEL COMPRESS TO HAVE JUST THE TAR FILE
40
- //VAR CREATION OUTSIDE OF ALL CONDITIONS, THEY ARE MUST HAVE VAR !!
39
+ //VAR CREATION OUTSIDE OF ALL CONDITIONS, THEY ARE "MUST HAVE" VAR !!
41
40
$ messages = ConfService::getMessages ();
42
41
$ repository = ConfService::getRepository ();
43
42
$ userSelection = new UserSelection ($ repository , $ httpVars );
@@ -62,7 +61,7 @@ public function receiveAction($action, $httpVars, $fileVars)
62
61
if ($ action == "compression " ) {
63
62
$ archiveName = AJXP_Utils::sanitize (AJXP_Utils::decodeSecureMagic ($ httpVars ["archiveName " ]), AJXP_SANITIZE_FILENAME );
64
63
$ archiveFormat = $ httpVars ["type_archive " ];
65
- $ tabTypeArchive = [ ".tar " , ".tar.gz " , ".tar.bz2 " ] ;
64
+ $ tabTypeArchive = array ( ".tar " , ".tar.gz " , ".tar.bz2 " ) ;
66
65
$ acceptedExtension = false ;
67
66
foreach ($ tabTypeArchive as $ extensionArchive ) {
68
67
if ($ extensionArchive == $ archiveFormat ) {
@@ -74,8 +73,8 @@ public function receiveAction($action, $httpVars, $fileVars)
74
73
throw new AJXP_Exception ($ messages ["compression.16 " ]);
75
74
}
76
75
$ typeArchive = $ httpVars ["type_archive " ];
77
- //if we can run in background we do it
78
- if (ConfService:: backgroundActionsSupported () && !ConfService:: currentContextIsCommandLine () ) {
76
+ //if we can run in background we do it ConfService::backgroundActionsSupported() && !ConfService::currentContextIsCommandLine()
77
+ if (1 == 2 ) {
79
78
$ archivePath = $ currentDirPath .$ archiveName ;
80
79
file_put_contents ($ progressCompressionFileName , $ messages ["compression.5 " ]);
81
80
AJXP_Controller::applyActionInBackground ($ repository ->getId (), "compression " , $ httpVars );
@@ -84,15 +83,15 @@ public function receiveAction($action, $httpVars, $fileVars)
84
83
"repository_id " => $ repository ->getId (),
85
84
"compression_id " => $ compressionId ,
86
85
"archive_path " => SystemTextEncoding::toUTF8 ($ archivePath )
87
- ), $ messages ["compression.5 " ], true , 4 );
86
+ ), $ messages ["compression.5 " ], true , 2 );
88
87
AJXP_XMLWriter::close ();
89
88
return null ;
90
89
} else {
91
90
$ maxAuthorizedSize = 4294967296 ;
92
91
$ currentDirUrlLength = strlen ($ currentDirUrl );
93
- $ tabFolders = [] ;
94
- $ tabAllRecursiveFiles = [] ;
95
- $ tabFilesNames = [] ;
92
+ $ tabFolders = array () ;
93
+ $ tabAllRecursiveFiles = array () ;
94
+ $ tabFilesNames = array () ;
96
95
foreach ($ nodes as $ node ) {
97
96
$ nodeUrl = $ node ->getUrl ();
98
97
if (is_file ($ nodeUrl ) && filesize ($ nodeUrl ) < $ maxAuthorizedSize ) {
@@ -127,7 +126,7 @@ public function receiveAction($action, $httpVars, $fileVars)
127
126
try {
128
127
$ archive ->addFile (AJXP_MetaStreamWrapper::getRealFSReference ($ fullPath ), $ fileName );
129
128
$ counterCompression ++;
130
- file_put_contents ($ progressCompressionFileName , sprintf ($ messages ["compression.6 " ], ( $ counterCompression / count ($ tabAllFiles )) * 100 . " % " ));
129
+ file_put_contents ($ progressCompressionFileName , sprintf ($ messages ["compression.6 " ], round (( $ counterCompression / count ($ tabAllFiles )) * 100 , 2 ) . " % " ));
131
130
} catch (Exception $ e ) {
132
131
unlink ($ tmpArchiveName );
133
132
throw $ e ;
@@ -165,7 +164,7 @@ public function receiveAction($action, $httpVars, $fileVars)
165
164
"repository_id " => $ repository ->getId (),
166
165
"compression_id " => $ compressionId ,
167
166
"archive_path " => SystemTextEncoding::toUTF8 ($ archivePath )
168
- ), $ progressCompression , true , 3 );
167
+ ), $ progressCompression , true , 5 );
169
168
AJXP_XMLWriter::close ();
170
169
} else {
171
170
$ newNode = new AJXP_Node ($ userSelection ->currentBaseUrl () . $ archivePath );
@@ -181,7 +180,7 @@ public function receiveAction($action, $httpVars, $fileVars)
181
180
elseif ($ action == "extraction " ) {
182
181
$ fileArchive = AJXP_Utils::sanitize (AJXP_Utils::decodeSecureMagic ($ httpVars ["file " ]), AJXP_SANITIZE_DIRNAME );
183
182
$ fileArchive = substr (strrchr ($ fileArchive , DIRECTORY_SEPARATOR ), 1 );
184
- $ authorizedExtension = [ "tar " => 4 , "gz " => 7 , "bz2 " => 8 ] ;
183
+ $ authorizedExtension = array ( "tar " => 4 , "gz " => 7 , "bz2 " => 8 ) ;
185
184
$ acceptedArchive = false ;
186
185
$ extensionLength = 0 ;
187
186
$ counterExtract = 0 ;
@@ -220,7 +219,7 @@ public function receiveAction($action, $httpVars, $fileVars)
220
219
"extraction_id " => $ extractId ,
221
220
"currentDirUrl " => $ currentDirUrl ,
222
221
"onlyFileName " => $ onlyFileName
223
- ), $ messages ["compression.12 " ], true , 3 );
222
+ ), $ messages ["compression.12 " ], true , 2 );
224
223
AJXP_XMLWriter::close ();
225
224
return null ;
226
225
}
@@ -240,7 +239,7 @@ public function receiveAction($action, $httpVars, $fileVars)
240
239
$ newNode = new AJXP_Node ($ currentDirUrl . $ onlyFileName . DIRECTORY_SEPARATOR . $ fileNameInArchive );
241
240
AJXP_Controller::applyHook ("node.change " , array (null , $ newNode , false ));
242
241
$ counterExtract ++;
243
- file_put_contents ($ progressExtractFileName , sprintf ($ messages ["compression.12 " ], ( $ counterExtract / $ archive ->count ()) * 100 . " % " ));
242
+ file_put_contents ($ progressExtractFileName , sprintf ($ messages ["compression.12 " ], round (( $ counterExtract / $ archive ->count ()) * 100 , 2 ) . " % " ));
244
243
}
245
244
} catch (Exception $ e ) {
246
245
throw new AJXP_Exception ($ e );
@@ -258,7 +257,7 @@ public function receiveAction($action, $httpVars, $fileVars)
258
257
"extraction_id " => $ extractId ,
259
258
"currentDirUrl " => $ currentDirUrl ,
260
259
"onlyFileName " => $ onlyFileName
261
- ), $ progressExtract , true , 3 );
260
+ ), $ progressExtract , true , 5 );
262
261
AJXP_XMLWriter::close ();
263
262
} else {
264
263
$ newNode = new AJXP_Node ($ currentDirUrl . $ onlyFileName );
0 commit comments