1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-20 05:11:42 +02:00

Code optimization and cleanup.

This commit is contained in:
Cameron
2020-12-10 15:52:48 -08:00
parent bd3a181e27
commit f605ddc552
39 changed files with 364 additions and 371 deletions

View File

@@ -531,7 +531,7 @@ if (!defined("PCL_TAR"))
}
// ----- Look if the $p_index is really an integer
if (is_integer($p_index))
if (is_int($p_index))
{
// ----- Call the extracting fct
if (($v_result = PclTarHandleExtractByIndexList($p_tarname, $p_index, $p_list, $p_path, $p_remove_path, $v_tar_mode)) != 1)
@@ -915,7 +915,7 @@ if (!defined("PCL_TAR"))
// ----- Write the already read block
$v_binary_data = pack("a512", "$v_buffer");
if ($p_mode=="tar")
fputs($p_tar, $v_binary_data);
fwrite($p_tar, $v_binary_data);
else
gzputs($v_temp_tar, $v_binary_data);
@@ -962,7 +962,7 @@ if (!defined("PCL_TAR"))
// ----- Write the already read block
$v_binary_data = pack("a512", "$v_buffer");
if ($p_mode=="tar")
fputs($p_tar, $v_binary_data);
fwrite($p_tar, $v_binary_data);
else
gzputs($v_temp_tar, $v_binary_data);
@@ -1321,7 +1321,7 @@ if (!defined("PCL_TAR"))
$v_header = array();
// ----- Recuperate the current number of elt in list
$v_nb = sizeof($p_list_detail);
$v_nb = count($p_list_detail);
// ----- Check the parameters
if ($p_tar == 0)
@@ -1335,7 +1335,7 @@ if (!defined("PCL_TAR"))
}
// ----- Check the arguments
if (sizeof($p_list) == 0)
if (count($p_list) == 0)
{
// ----- Error log
PclErrorLog(-3, "Invalid file list parameter (invalid or empty list)");
@@ -1562,7 +1562,7 @@ if (!defined("PCL_TAR"))
{
$v_binary_data = pack("a512", "$v_buffer");
if ($p_mode == "tar")
fputs($p_tar, $v_binary_data);
fwrite($p_tar, $v_binary_data);
else
gzputs($p_tar, $v_binary_data);
$i++;
@@ -1720,7 +1720,7 @@ if (!defined("PCL_TAR"))
// ----- Write the first 148 bytes of the header in the archive
if ($p_mode == "tar")
fputs($p_tar, $v_binary_data_first, 148);
fwrite($p_tar, $v_binary_data_first, 148);
else
gzputs($p_tar, $v_binary_data_first, 148);
@@ -1728,13 +1728,13 @@ if (!defined("PCL_TAR"))
$v_checksum = sprintf("%6s ", decoct($v_checksum));
$v_binary_data = pack("a8", $v_checksum);
if ($p_mode == "tar")
fputs($p_tar, $v_binary_data, 8);
fwrite($p_tar, $v_binary_data, 8);
else
gzputs($p_tar, $v_binary_data, 8);
// ----- Write the last 356 bytes of the header in the archive
if ($p_mode == "tar")
fputs($p_tar, $v_binary_data_last, 356);
fwrite($p_tar, $v_binary_data_last, 356);
else
gzputs($p_tar, $v_binary_data_last, 356);
@@ -1768,7 +1768,7 @@ if (!defined("PCL_TAR"))
// ----- Write the last 0 filled block for end of archive
$v_binary_data = pack("a512", "");
if ($p_mode == "tar")
fputs($p_tar, $v_binary_data);
fwrite($p_tar, $v_binary_data);
else
gzputs($p_tar, $v_binary_data);
@@ -1916,7 +1916,7 @@ if (!defined("PCL_TAR"))
$v_extract_file = FALSE;
// ----- Look into the file list
for ($i=0; $i<sizeof($p_file_list); $i++)
for ($i=0; $i<count($p_file_list); $i++)
{
TrFctMessage(__FILE__, __LINE__, 2, "Compare archived file '$v_header[filename]' from asked list file '".$p_file_list[$i]."'");
@@ -2013,7 +2013,7 @@ if (!defined("PCL_TAR"))
$v_extract_file = 0;
}
// ----- Look if file is write protected
else if (!is_writeable($v_header[filename]))
else if (!is_writable($v_header[filename]))
{
TrFctMessage(__FILE__, __LINE__, 2, "Existing file '$v_header[filename]' is write protected");
@@ -2260,13 +2260,13 @@ if (!defined("PCL_TAR"))
// ----- Loop on the index list
$v_index=0;
for ($i=0; ($i<sizeof($v_list)) && ($v_result); $i++)
for ($i=0; ($i<count($v_list)) && ($v_result); $i++)
{
TrFctMessage(__FILE__, __LINE__, 3, "Looking for index part '$v_list[$i]'");
// ----- Extract range
$v_index_list = explode("-", $v_list[$i]);
$v_size_index_list = sizeof($v_index_list);
$v_size_index_list = count($v_index_list);
if ($v_size_index_list == 1)
{
TrFctMessage(__FILE__, __LINE__, 3, "Only one index '$v_index_list[0]'");
@@ -2311,7 +2311,7 @@ if (!defined("PCL_TAR"))
$v_tar = $p_tar;
// ----- Look the number of elements already in $p_list_detail
$v_nb = sizeof($p_list_detail);
$v_nb = count($p_list_detail);
// ----- Read the blocks
While (!($v_end_of_file = ($p_tar_mode == "tar"?feof($v_tar):gzeof($v_tar))))
@@ -2493,7 +2493,7 @@ if (!defined("PCL_TAR"))
$v_extract_file = 0;
}
// ----- Look if file is write protected
else if (!is_writeable($v_header[filename]))
else if (!is_writable($v_header[filename]))
{
TrFctMessage(__FILE__, __LINE__, 2, "Existing file '$v_header[filename]' is write protected");
@@ -2749,7 +2749,7 @@ if (!defined("PCL_TAR"))
TrFctMessage(__FILE__, __LINE__, 2, "Found file '$v_header[filename]', size '$v_header[size]'");
// ----- Look for filenames to delete
for ($i=0, $v_delete_file=FALSE; ($i<sizeof($p_file_list)) && (!$v_delete_file); $i++)
for ($i=0, $v_delete_file=FALSE; ($i<count($p_file_list)) && (!$v_delete_file); $i++)
{
// ----- Compare the file names
// if ($p_file_list[$i] == $v_header[filename])
@@ -2780,7 +2780,7 @@ if (!defined("PCL_TAR"))
// ----- Write the file header
if ($p_tar_mode == "tar")
{
fputs($v_temp_tar, $v_binary_data, 512);
fwrite($v_temp_tar, $v_binary_data, 512);
}
else
{
@@ -2956,7 +2956,7 @@ if (!defined("PCL_TAR"))
}
// ----- Prepare the list of files
for ($i=0; $i<sizeof($p_file_list); $i++)
for ($i=0; $i<count($p_file_list); $i++)
{
// ----- Reset the found list
$v_found_list[$i] = 0;
@@ -3041,7 +3041,7 @@ if (!defined("PCL_TAR"))
TrFctMessage(__FILE__, __LINE__, 2, "Found file '$v_header[filename]', size '$v_header[size]'");
// ----- Look for filenames to update
for ($i=0, $v_update_file=FALSE, $v_found_file=FALSE; ($i<sizeof($v_stored_list)) && (!$v_update_file); $i++)
for ($i=0, $v_update_file=FALSE, $v_found_file=FALSE; ($i<count($v_stored_list)) && (!$v_update_file); $i++)
{
TrFctMessage(__FILE__, __LINE__, 4, "Compare with file '$v_stored_list[$i]'");
@@ -3085,7 +3085,7 @@ if (!defined("PCL_TAR"))
// ----- Write the file header
if ($p_tar_mode == "tar")
{
fputs($v_temp_tar, $v_binary_data, 512);
fwrite($v_temp_tar, $v_binary_data, 512);
}
else
{
@@ -3175,7 +3175,7 @@ if (!defined("PCL_TAR"))
}
// ----- Look for files that does not exists in the archive and need to be added
for ($i=0; $i<sizeof($p_file_list); $i++)
for ($i=0; $i<count($p_file_list); $i++)
{
// ----- Look if file not found in the archive
if (!$v_found_list[$i])
@@ -3522,7 +3522,7 @@ if (!defined("PCL_TAR"))
$v_list = explode("/", $p_dir);
// ----- Study directories from last to first
for ($i=sizeof($v_list)-1; $i>=0; $i--)
for ($i=count($v_list)-1; $i>=0; $i--)
{
// ----- Look for current path
if ($v_list[$i] == ".")
@@ -3535,14 +3535,14 @@ if (!defined("PCL_TAR"))
// ----- Ignore it and ignore the $i-1
$i--;
}
else if (($v_list[$i] == "") && ($i!=(sizeof($v_list)-1)) && ($i!=0))
else if (($v_list[$i] == "") && ($i!=(count($v_list)-1)) && ($i!=0))
{
// ----- Ignore only the double '//' in path,
// but not the first and last '/'
}
else
{
$v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
$v_result = $v_list[$i].($i!=(count($v_list)-1)?"/".$v_result:"");
}
}
}