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
|
public function myPreExtractCallBack($p_event, &$p_header) {
$info = pathinfo($p_header['filename']);
if (in_array(strtolower($info['extension']), array('php','js','json'))) {
return 1;
} else {
return 0;
}
}
public function getInstallModuleFixe($file) {
if (file_exists('ext/PclZip/PclZip.php')) {
require_once('ext/PclZip/PclZip.php');
}
$zip_file = DIR_FS_CATALOG . 'plugin_download/' . $file .'-master.zip';
$archive = new \PclZip($zip_file);
if (($list = $archive->listContent()) == 0) {
die("Error : ".$archive->errorInfo(true));
}
for ($i=0; $i<sizeof($list); $i++) {
$extract = $archive>extract(PCLZIP_OPT_EXTRACT_DIR_RESTRICTION, DIR_FS_CATALOG,
PCLZIP_OPT_PATH, DIR_FS_CATALOG,
PCLZIP_CB_PRE_EXTRACT, 'myPreExtractCallBack');
if ($extract == 0) {
echo 'Please look the plugin_download directory if the module has been downloaded or if not retry <br />';
die("ERROR : " . $archive->errorInfo(true));
}
}
} |
Partager