extract-class

Gesponsorde koppelingen

PHP script bestanden

  1. extract-class

« Lees de omschrijving en reacties

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php

// $exdir is the directory you want the content of the compressed file to be extracted
// use for the value of exdir unix style
// if overwrite is 1 old files with same names will be replaced, if 0 old files will be spared :P


class extract
{

// used to extract zip files
// if password is filled in the zip file will be encrypted

function extract_zip($file,$overwrite=0,$exdir="",$password=""){
    
    //building the command    
    $para['password']  = (!empty($password)) ? "-P ".$password." " : "";
    $para['overwrite'] = ($overwrite == 1) ? " -o " : " -n ";
    $para['exdir']     = (!empty($exdir)) ? "-d ".$exdir." " : "";
    exec("unzip".$para['overwrite'].$para['password']." ".$file." ".$para['exdir']);
    
}



// used to extract gz files
function extract_gz($file,$overwrite=0,$exdir=""){
    
    //building the command
    $para['overwrite'] = ($overwrite == 1) ? "" : " -k";
    $para['exdir']     = (!empty($exdir)) ? "-C ".$exdir." " : "";
    echo exec("tar -zxf ".$file." ".$para['exdir'].$para['overwrite']);
    
}



// used to extract bz2 files
function extract_bz2($file,$overwrite=0,$exdir=""){
    
    //building the command
    $para['overwrite'] = ($overwrite == 1) ? "" : " -k";
    $para['exdir']     = (!empty($exdir)) ? "-C ".$exdir." " : "";
    exec("tar -jxf ".$file." ".$para['exdir'].$para['overwrite']);    
    
}


// end of class
// in the future i will build a check that will verify the extracted files.

}

// example
$test = new extract();
$test->extract_gz("test.tar.gz",1"./output");

// another example
extract::extract_gz("test.tar.gz",1"./output");
?>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.