Edit File by line
/home/barbar84/www/extracte.../filemang...
File: pclzip.lib.php
// PCLZIP_OPT_BY_NAME :
[1000] Fix | Delete
// PCLZIP_OPT_BY_EREG :
[1001] Fix | Delete
// PCLZIP_OPT_BY_PREG :
[1002] Fix | Delete
// Return Values :
[1003] Fix | Delete
// 0 on failure,
[1004] Fix | Delete
// The list of the files which are still present in the archive.
[1005] Fix | Delete
// (see PclZip::listContent() for list entry format)
[1006] Fix | Delete
// --------------------------------------------------------------------------------
[1007] Fix | Delete
function delete()
[1008] Fix | Delete
{
[1009] Fix | Delete
$v_result=1;
[1010] Fix | Delete
[1011] Fix | Delete
// ----- Reset the error handler
[1012] Fix | Delete
$this->privErrorReset();
[1013] Fix | Delete
[1014] Fix | Delete
// ----- Check archive
[1015] Fix | Delete
if (!$this->privCheckFormat()) {
[1016] Fix | Delete
return(0);
[1017] Fix | Delete
}
[1018] Fix | Delete
[1019] Fix | Delete
// ----- Set default values
[1020] Fix | Delete
$v_options = array();
[1021] Fix | Delete
[1022] Fix | Delete
// ----- Look for variable options arguments
[1023] Fix | Delete
$v_size = func_num_args();
[1024] Fix | Delete
[1025] Fix | Delete
// ----- Look for arguments
[1026] Fix | Delete
if ($v_size > 0) {
[1027] Fix | Delete
// ----- Get the arguments
[1028] Fix | Delete
$v_arg_list = func_get_args();
[1029] Fix | Delete
[1030] Fix | Delete
// ----- Parse the options
[1031] Fix | Delete
$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
[1032] Fix | Delete
array (PCLZIP_OPT_BY_NAME => 'optional',
[1033] Fix | Delete
PCLZIP_OPT_BY_EREG => 'optional',
[1034] Fix | Delete
PCLZIP_OPT_BY_PREG => 'optional',
[1035] Fix | Delete
PCLZIP_OPT_BY_INDEX => 'optional' ));
[1036] Fix | Delete
if ($v_result != 1) {
[1037] Fix | Delete
return 0;
[1038] Fix | Delete
}
[1039] Fix | Delete
}
[1040] Fix | Delete
[1041] Fix | Delete
// ----- Magic quotes trick
[1042] Fix | Delete
$this->privDisableMagicQuotes();
[1043] Fix | Delete
[1044] Fix | Delete
// ----- Call the delete fct
[1045] Fix | Delete
$v_list = array();
[1046] Fix | Delete
if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) {
[1047] Fix | Delete
$this->privSwapBackMagicQuotes();
[1048] Fix | Delete
unset($v_list);
[1049] Fix | Delete
return(0);
[1050] Fix | Delete
}
[1051] Fix | Delete
[1052] Fix | Delete
// ----- Magic quotes trick
[1053] Fix | Delete
$this->privSwapBackMagicQuotes();
[1054] Fix | Delete
[1055] Fix | Delete
// ----- Return
[1056] Fix | Delete
return $v_list;
[1057] Fix | Delete
}
[1058] Fix | Delete
// --------------------------------------------------------------------------------
[1059] Fix | Delete
[1060] Fix | Delete
// --------------------------------------------------------------------------------
[1061] Fix | Delete
// Function : deleteByIndex()
[1062] Fix | Delete
// Description :
[1063] Fix | Delete
// ***** Deprecated *****
[1064] Fix | Delete
// delete(PCLZIP_OPT_BY_INDEX, $p_index) should be prefered.
[1065] Fix | Delete
// --------------------------------------------------------------------------------
[1066] Fix | Delete
function deleteByIndex($p_index)
[1067] Fix | Delete
{
[1068] Fix | Delete
[1069] Fix | Delete
$p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index);
[1070] Fix | Delete
[1071] Fix | Delete
// ----- Return
[1072] Fix | Delete
return $p_list;
[1073] Fix | Delete
}
[1074] Fix | Delete
// --------------------------------------------------------------------------------
[1075] Fix | Delete
[1076] Fix | Delete
// --------------------------------------------------------------------------------
[1077] Fix | Delete
// Function : properties()
[1078] Fix | Delete
// Description :
[1079] Fix | Delete
// This method gives the properties of the archive.
[1080] Fix | Delete
// The properties are :
[1081] Fix | Delete
// nb : Number of files in the archive
[1082] Fix | Delete
// comment : Comment associated with the archive file
[1083] Fix | Delete
// status : not_exist, ok
[1084] Fix | Delete
// Parameters :
[1085] Fix | Delete
// None
[1086] Fix | Delete
// Return Values :
[1087] Fix | Delete
// 0 on failure,
[1088] Fix | Delete
// An array with the archive properties.
[1089] Fix | Delete
// --------------------------------------------------------------------------------
[1090] Fix | Delete
function properties()
[1091] Fix | Delete
{
[1092] Fix | Delete
[1093] Fix | Delete
// ----- Reset the error handler
[1094] Fix | Delete
$this->privErrorReset();
[1095] Fix | Delete
[1096] Fix | Delete
// ----- Magic quotes trick
[1097] Fix | Delete
$this->privDisableMagicQuotes();
[1098] Fix | Delete
[1099] Fix | Delete
// ----- Check archive
[1100] Fix | Delete
if (!$this->privCheckFormat()) {
[1101] Fix | Delete
$this->privSwapBackMagicQuotes();
[1102] Fix | Delete
return(0);
[1103] Fix | Delete
}
[1104] Fix | Delete
[1105] Fix | Delete
// ----- Default properties
[1106] Fix | Delete
$v_prop = array();
[1107] Fix | Delete
$v_prop['comment'] = '';
[1108] Fix | Delete
$v_prop['nb'] = 0;
[1109] Fix | Delete
$v_prop['status'] = 'not_exist';
[1110] Fix | Delete
[1111] Fix | Delete
// ----- Look if file exists
[1112] Fix | Delete
if (@is_file($this->zipname))
[1113] Fix | Delete
{
[1114] Fix | Delete
// ----- Open the zip file
[1115] Fix | Delete
if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
[1116] Fix | Delete
{
[1117] Fix | Delete
$this->privSwapBackMagicQuotes();
[1118] Fix | Delete
[1119] Fix | Delete
// ----- Error log
[1120] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
[1121] Fix | Delete
[1122] Fix | Delete
// ----- Return
[1123] Fix | Delete
return 0;
[1124] Fix | Delete
}
[1125] Fix | Delete
[1126] Fix | Delete
// ----- Read the central directory informations
[1127] Fix | Delete
$v_central_dir = array();
[1128] Fix | Delete
if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
[1129] Fix | Delete
{
[1130] Fix | Delete
$this->privSwapBackMagicQuotes();
[1131] Fix | Delete
return 0;
[1132] Fix | Delete
}
[1133] Fix | Delete
[1134] Fix | Delete
// ----- Close the zip file
[1135] Fix | Delete
$this->privCloseFd();
[1136] Fix | Delete
[1137] Fix | Delete
// ----- Set the user attributes
[1138] Fix | Delete
$v_prop['comment'] = $v_central_dir['comment'];
[1139] Fix | Delete
$v_prop['nb'] = $v_central_dir['entries'];
[1140] Fix | Delete
$v_prop['status'] = 'ok';
[1141] Fix | Delete
}
[1142] Fix | Delete
[1143] Fix | Delete
// ----- Magic quotes trick
[1144] Fix | Delete
$this->privSwapBackMagicQuotes();
[1145] Fix | Delete
[1146] Fix | Delete
// ----- Return
[1147] Fix | Delete
return $v_prop;
[1148] Fix | Delete
}
[1149] Fix | Delete
// --------------------------------------------------------------------------------
[1150] Fix | Delete
[1151] Fix | Delete
// --------------------------------------------------------------------------------
[1152] Fix | Delete
// Function : duplicate()
[1153] Fix | Delete
// Description :
[1154] Fix | Delete
// This method creates an archive by copying the content of an other one. If
[1155] Fix | Delete
// the archive already exist, it is replaced by the new one without any warning.
[1156] Fix | Delete
// Parameters :
[1157] Fix | Delete
// $p_archive : The filename of a valid archive, or
[1158] Fix | Delete
// a valid PclZip object.
[1159] Fix | Delete
// Return Values :
[1160] Fix | Delete
// 1 on success.
[1161] Fix | Delete
// 0 or a negative value on error (error code).
[1162] Fix | Delete
// --------------------------------------------------------------------------------
[1163] Fix | Delete
function duplicate($p_archive)
[1164] Fix | Delete
{
[1165] Fix | Delete
$v_result = 1;
[1166] Fix | Delete
[1167] Fix | Delete
// ----- Reset the error handler
[1168] Fix | Delete
$this->privErrorReset();
[1169] Fix | Delete
[1170] Fix | Delete
// ----- Look if the $p_archive is a PclZip object
[1171] Fix | Delete
if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip'))
[1172] Fix | Delete
{
[1173] Fix | Delete
[1174] Fix | Delete
// ----- Duplicate the archive
[1175] Fix | Delete
$v_result = $this->privDuplicate($p_archive->zipname);
[1176] Fix | Delete
}
[1177] Fix | Delete
[1178] Fix | Delete
// ----- Look if the $p_archive is a string (so a filename)
[1179] Fix | Delete
else if (is_string($p_archive))
[1180] Fix | Delete
{
[1181] Fix | Delete
[1182] Fix | Delete
// ----- Check that $p_archive is a valid zip file
[1183] Fix | Delete
// TBC : Should also check the archive format
[1184] Fix | Delete
if (!is_file($p_archive)) {
[1185] Fix | Delete
// ----- Error log
[1186] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'");
[1187] Fix | Delete
$v_result = PCLZIP_ERR_MISSING_FILE;
[1188] Fix | Delete
}
[1189] Fix | Delete
else {
[1190] Fix | Delete
// ----- Duplicate the archive
[1191] Fix | Delete
$v_result = $this->privDuplicate($p_archive);
[1192] Fix | Delete
}
[1193] Fix | Delete
}
[1194] Fix | Delete
[1195] Fix | Delete
// ----- Invalid variable
[1196] Fix | Delete
else
[1197] Fix | Delete
{
[1198] Fix | Delete
// ----- Error log
[1199] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
[1200] Fix | Delete
$v_result = PCLZIP_ERR_INVALID_PARAMETER;
[1201] Fix | Delete
}
[1202] Fix | Delete
[1203] Fix | Delete
// ----- Return
[1204] Fix | Delete
return $v_result;
[1205] Fix | Delete
}
[1206] Fix | Delete
// --------------------------------------------------------------------------------
[1207] Fix | Delete
[1208] Fix | Delete
// --------------------------------------------------------------------------------
[1209] Fix | Delete
// Function : merge()
[1210] Fix | Delete
// Description :
[1211] Fix | Delete
// This method merge the $p_archive_to_add archive at the end of the current
[1212] Fix | Delete
// one ($this).
[1213] Fix | Delete
// If the archive ($this) does not exist, the merge becomes a duplicate.
[1214] Fix | Delete
// If the $p_archive_to_add archive does not exist, the merge is a success.
[1215] Fix | Delete
// Parameters :
[1216] Fix | Delete
// $p_archive_to_add : It can be directly the filename of a valid zip archive,
[1217] Fix | Delete
// or a PclZip object archive.
[1218] Fix | Delete
// Return Values :
[1219] Fix | Delete
// 1 on success,
[1220] Fix | Delete
// 0 or negative values on error (see below).
[1221] Fix | Delete
// --------------------------------------------------------------------------------
[1222] Fix | Delete
function merge($p_archive_to_add)
[1223] Fix | Delete
{
[1224] Fix | Delete
$v_result = 1;
[1225] Fix | Delete
[1226] Fix | Delete
// ----- Reset the error handler
[1227] Fix | Delete
$this->privErrorReset();
[1228] Fix | Delete
[1229] Fix | Delete
// ----- Check archive
[1230] Fix | Delete
if (!$this->privCheckFormat()) {
[1231] Fix | Delete
return(0);
[1232] Fix | Delete
}
[1233] Fix | Delete
[1234] Fix | Delete
// ----- Look if the $p_archive_to_add is a PclZip object
[1235] Fix | Delete
if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip'))
[1236] Fix | Delete
{
[1237] Fix | Delete
[1238] Fix | Delete
// ----- Merge the archive
[1239] Fix | Delete
$v_result = $this->privMerge($p_archive_to_add);
[1240] Fix | Delete
}
[1241] Fix | Delete
[1242] Fix | Delete
// ----- Look if the $p_archive_to_add is a string (so a filename)
[1243] Fix | Delete
else if (is_string($p_archive_to_add))
[1244] Fix | Delete
{
[1245] Fix | Delete
[1246] Fix | Delete
// ----- Create a temporary archive
[1247] Fix | Delete
$v_object_archive = new PclZip($p_archive_to_add);
[1248] Fix | Delete
[1249] Fix | Delete
// ----- Merge the archive
[1250] Fix | Delete
$v_result = $this->privMerge($v_object_archive);
[1251] Fix | Delete
}
[1252] Fix | Delete
[1253] Fix | Delete
// ----- Invalid variable
[1254] Fix | Delete
else
[1255] Fix | Delete
{
[1256] Fix | Delete
// ----- Error log
[1257] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
[1258] Fix | Delete
$v_result = PCLZIP_ERR_INVALID_PARAMETER;
[1259] Fix | Delete
}
[1260] Fix | Delete
[1261] Fix | Delete
// ----- Return
[1262] Fix | Delete
return $v_result;
[1263] Fix | Delete
}
[1264] Fix | Delete
// --------------------------------------------------------------------------------
[1265] Fix | Delete
[1266] Fix | Delete
[1267] Fix | Delete
[1268] Fix | Delete
// --------------------------------------------------------------------------------
[1269] Fix | Delete
// Function : errorCode()
[1270] Fix | Delete
// Description :
[1271] Fix | Delete
// Parameters :
[1272] Fix | Delete
// --------------------------------------------------------------------------------
[1273] Fix | Delete
function errorCode()
[1274] Fix | Delete
{
[1275] Fix | Delete
if (PCLZIP_ERROR_EXTERNAL == 1) {
[1276] Fix | Delete
return(PclErrorCode());
[1277] Fix | Delete
}
[1278] Fix | Delete
else {
[1279] Fix | Delete
return($this->error_code);
[1280] Fix | Delete
}
[1281] Fix | Delete
}
[1282] Fix | Delete
// --------------------------------------------------------------------------------
[1283] Fix | Delete
[1284] Fix | Delete
// --------------------------------------------------------------------------------
[1285] Fix | Delete
// Function : errorName()
[1286] Fix | Delete
// Description :
[1287] Fix | Delete
// Parameters :
[1288] Fix | Delete
// --------------------------------------------------------------------------------
[1289] Fix | Delete
function errorName($p_with_code=false)
[1290] Fix | Delete
{
[1291] Fix | Delete
$v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR',
[1292] Fix | Delete
PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL',
[1293] Fix | Delete
PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL',
[1294] Fix | Delete
PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER',
[1295] Fix | Delete
PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE',
[1296] Fix | Delete
PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG',
[1297] Fix | Delete
PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP',
[1298] Fix | Delete
PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE',
[1299] Fix | Delete
PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL',
[1300] Fix | Delete
PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION',
[1301] Fix | Delete
PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT',
[1302] Fix | Delete
PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL',
[1303] Fix | Delete
PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL',
[1304] Fix | Delete
PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM',
[1305] Fix | Delete
PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP',
[1306] Fix | Delete
PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE',
[1307] Fix | Delete
PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE',
[1308] Fix | Delete
PCLZIP_ERR_UNSUPPORTED_COMPRESSION => 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION',
[1309] Fix | Delete
PCLZIP_ERR_UNSUPPORTED_ENCRYPTION => 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION'
[1310] Fix | Delete
,PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE => 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE'
[1311] Fix | Delete
,PCLZIP_ERR_DIRECTORY_RESTRICTION => 'PCLZIP_ERR_DIRECTORY_RESTRICTION'
[1312] Fix | Delete
);
[1313] Fix | Delete
[1314] Fix | Delete
if (isset($v_name[$this->error_code])) {
[1315] Fix | Delete
$v_value = $v_name[$this->error_code];
[1316] Fix | Delete
}
[1317] Fix | Delete
else {
[1318] Fix | Delete
$v_value = 'NoName';
[1319] Fix | Delete
}
[1320] Fix | Delete
[1321] Fix | Delete
if ($p_with_code) {
[1322] Fix | Delete
return($v_value.' ('.$this->error_code.')');
[1323] Fix | Delete
}
[1324] Fix | Delete
else {
[1325] Fix | Delete
return($v_value);
[1326] Fix | Delete
}
[1327] Fix | Delete
}
[1328] Fix | Delete
// --------------------------------------------------------------------------------
[1329] Fix | Delete
[1330] Fix | Delete
// --------------------------------------------------------------------------------
[1331] Fix | Delete
// Function : errorInfo()
[1332] Fix | Delete
// Description :
[1333] Fix | Delete
// Parameters :
[1334] Fix | Delete
// --------------------------------------------------------------------------------
[1335] Fix | Delete
function errorInfo($p_full=false)
[1336] Fix | Delete
{
[1337] Fix | Delete
if (PCLZIP_ERROR_EXTERNAL == 1) {
[1338] Fix | Delete
return(PclErrorString());
[1339] Fix | Delete
}
[1340] Fix | Delete
else {
[1341] Fix | Delete
if ($p_full) {
[1342] Fix | Delete
return($this->errorName(true)." : ".$this->error_string);
[1343] Fix | Delete
}
[1344] Fix | Delete
else {
[1345] Fix | Delete
return($this->error_string." [code ".$this->error_code."]");
[1346] Fix | Delete
}
[1347] Fix | Delete
}
[1348] Fix | Delete
}
[1349] Fix | Delete
// --------------------------------------------------------------------------------
[1350] Fix | Delete
[1351] Fix | Delete
[1352] Fix | Delete
// --------------------------------------------------------------------------------
[1353] Fix | Delete
// ***** UNDER THIS LINE ARE DEFINED PRIVATE INTERNAL FUNCTIONS *****
[1354] Fix | Delete
// ***** *****
[1355] Fix | Delete
// ***** THESES FUNCTIONS MUST NOT BE USED DIRECTLY *****
[1356] Fix | Delete
// --------------------------------------------------------------------------------
[1357] Fix | Delete
[1358] Fix | Delete
[1359] Fix | Delete
[1360] Fix | Delete
// --------------------------------------------------------------------------------
[1361] Fix | Delete
// Function : privCheckFormat()
[1362] Fix | Delete
// Description :
[1363] Fix | Delete
// This method check that the archive exists and is a valid zip archive.
[1364] Fix | Delete
// Several level of check exists. (futur)
[1365] Fix | Delete
// Parameters :
[1366] Fix | Delete
// $p_level : Level of check. Default 0.
[1367] Fix | Delete
// 0 : Check the first bytes (magic codes) (default value))
[1368] Fix | Delete
// 1 : 0 + Check the central directory (futur)
[1369] Fix | Delete
// 2 : 1 + Check each file header (futur)
[1370] Fix | Delete
// Return Values :
[1371] Fix | Delete
// true on success,
[1372] Fix | Delete
// false on error, the error code is set.
[1373] Fix | Delete
// --------------------------------------------------------------------------------
[1374] Fix | Delete
function privCheckFormat($p_level=0)
[1375] Fix | Delete
{
[1376] Fix | Delete
$v_result = true;
[1377] Fix | Delete
[1378] Fix | Delete
// ----- Reset the file system cache
[1379] Fix | Delete
clearstatcache();
[1380] Fix | Delete
[1381] Fix | Delete
// ----- Reset the error handler
[1382] Fix | Delete
$this->privErrorReset();
[1383] Fix | Delete
[1384] Fix | Delete
// ----- Look if the file exits
[1385] Fix | Delete
if (!is_file($this->zipname)) {
[1386] Fix | Delete
// ----- Error log
[1387] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'");
[1388] Fix | Delete
return(false);
[1389] Fix | Delete
}
[1390] Fix | Delete
[1391] Fix | Delete
// ----- Check that the file is readeable
[1392] Fix | Delete
if (!is_readable($this->zipname)) {
[1393] Fix | Delete
// ----- Error log
[1394] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'");
[1395] Fix | Delete
return(false);
[1396] Fix | Delete
}
[1397] Fix | Delete
[1398] Fix | Delete
// ----- Check the magic code
[1399] Fix | Delete
// TBC
[1400] Fix | Delete
[1401] Fix | Delete
// ----- Check the central header
[1402] Fix | Delete
// TBC
[1403] Fix | Delete
[1404] Fix | Delete
// ----- Check each file header
[1405] Fix | Delete
// TBC
[1406] Fix | Delete
[1407] Fix | Delete
// ----- Return
[1408] Fix | Delete
return $v_result;
[1409] Fix | Delete
}
[1410] Fix | Delete
// --------------------------------------------------------------------------------
[1411] Fix | Delete
[1412] Fix | Delete
// --------------------------------------------------------------------------------
[1413] Fix | Delete
// Function : privParseOptions()
[1414] Fix | Delete
// Description :
[1415] Fix | Delete
// This internal methods reads the variable list of arguments ($p_options_list,
[1416] Fix | Delete
// $p_size) and generate an array with the options and values ($v_result_list).
[1417] Fix | Delete
// $v_requested_options contains the options that can be present and those that
[1418] Fix | Delete
// must be present.
[1419] Fix | Delete
// $v_requested_options is an array, with the option value as key, and 'optional',
[1420] Fix | Delete
// or 'mandatory' as value.
[1421] Fix | Delete
// Parameters :
[1422] Fix | Delete
// See above.
[1423] Fix | Delete
// Return Values :
[1424] Fix | Delete
// 1 on success.
[1425] Fix | Delete
// 0 on failure.
[1426] Fix | Delete
// --------------------------------------------------------------------------------
[1427] Fix | Delete
function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false)
[1428] Fix | Delete
{
[1429] Fix | Delete
$v_result=1;
[1430] Fix | Delete
[1431] Fix | Delete
// ----- Read the options
[1432] Fix | Delete
$i=0;
[1433] Fix | Delete
while ($i<$p_size) {
[1434] Fix | Delete
[1435] Fix | Delete
// ----- Check if the option is supported
[1436] Fix | Delete
if (!isset($v_requested_options[$p_options_list[$i]])) {
[1437] Fix | Delete
// ----- Error log
[1438] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method");
[1439] Fix | Delete
[1440] Fix | Delete
// ----- Return
[1441] Fix | Delete
return PclZip::errorCode();
[1442] Fix | Delete
}
[1443] Fix | Delete
[1444] Fix | Delete
// ----- Look for next option
[1445] Fix | Delete
switch ($p_options_list[$i]) {
[1446] Fix | Delete
// ----- Look for options that request a path value
[1447] Fix | Delete
case PCLZIP_OPT_PATH :
[1448] Fix | Delete
case PCLZIP_OPT_RECopy_PATH :
[1449] Fix | Delete
case PCLZIP_OPT_ADD_PATH :
[1450] Fix | Delete
// ----- Check the number of parameters
[1451] Fix | Delete
if (($i+1) >= $p_size) {
[1452] Fix | Delete
// ----- Error log
[1453] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
[1454] Fix | Delete
[1455] Fix | Delete
// ----- Return
[1456] Fix | Delete
return PclZip::errorCode();
[1457] Fix | Delete
}
[1458] Fix | Delete
[1459] Fix | Delete
// ----- Get the value
[1460] Fix | Delete
$v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
[1461] Fix | Delete
$i++;
[1462] Fix | Delete
break;
[1463] Fix | Delete
[1464] Fix | Delete
case PCLZIP_OPT_TEMP_FILE_THRESHOLD :
[1465] Fix | Delete
// ----- Check the number of parameters
[1466] Fix | Delete
if (($i+1) >= $p_size) {
[1467] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
[1468] Fix | Delete
return PclZip::errorCode();
[1469] Fix | Delete
}
[1470] Fix | Delete
[1471] Fix | Delete
// ----- Check for incompatible options
[1472] Fix | Delete
if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
[1473] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
[1474] Fix | Delete
return PclZip::errorCode();
[1475] Fix | Delete
}
[1476] Fix | Delete
[1477] Fix | Delete
// ----- Check the value
[1478] Fix | Delete
$v_value = $p_options_list[$i+1];
[1479] Fix | Delete
if ((!is_integer($v_value)) || ($v_value<0)) {
[1480] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".PclZipUtilOptionText($p_options_list[$i])."'");
[1481] Fix | Delete
return PclZip::errorCode();
[1482] Fix | Delete
}
[1483] Fix | Delete
[1484] Fix | Delete
// ----- Get the value (and convert it in bytes)
[1485] Fix | Delete
$v_result_list[$p_options_list[$i]] = $v_value*1048576;
[1486] Fix | Delete
$i++;
[1487] Fix | Delete
break;
[1488] Fix | Delete
[1489] Fix | Delete
case PCLZIP_OPT_TEMP_FILE_ON :
[1490] Fix | Delete
// ----- Check for incompatible options
[1491] Fix | Delete
if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
[1492] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
[1493] Fix | Delete
return PclZip::errorCode();
[1494] Fix | Delete
}
[1495] Fix | Delete
[1496] Fix | Delete
$v_result_list[$p_options_list[$i]] = true;
[1497] Fix | Delete
break;
[1498] Fix | Delete
[1499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function