privWriteCentralFileHeader($v_header_list[$i])) != 1) { $v_temp_zip->privCloseFd(); $this->privCloseFd(); @unlink($v_zip_temp_name); return $v_result; } $v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); } $v_comment = ''; if (isset($p_options[PCLZIP_OPT_COMMENT])) { $v_comment = $p_options[PCLZIP_OPT_COMMENT]; } $v_size = @ftell($v_temp_zip->zip_fd)-$v_offset; if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) { unset($v_header_list); $v_temp_zip->privCloseFd(); $this->privCloseFd(); @unlink($v_zip_temp_name); return $v_result; } $v_temp_zip->privCloseFd(); $this->privCloseFd(); @unlink($this->zipname); PclZipUtilRename($v_zip_temp_name, $this->zipname); unset($v_temp_zip); } else if ($v_central_dir['entries'] != 0) { $this->privCloseFd(); if (($v_result = $this->privOpenFd('wb')) != 1) { return $v_result; } if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) { return $v_result; } $this->privCloseFd(); } return $v_result; } function privDirCheck($p_dir, $p_is_dir=false) { $v_result = 1; if (($p_is_dir) && (substr($p_dir, -1)=='/')) { $p_dir = substr($p_dir, 0, strlen($p_dir)-1); } if ((is_dir($p_dir)) || ($p_dir == "")) { return 1; } $p_parent_dir = dirname($p_dir); if ($p_parent_dir != $p_dir) { if ($p_parent_dir != "") { if (($v_result = $this->privDirCheck($p_parent_dir)) != 1) { return $v_result; } } } if (!@mkdir($p_dir, 0777)) { PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'"); return PclZip::errorCode(); } return $v_result; } function privMerge(&$p_archive_to_add) { $v_result=1; if (!is_file($p_archive_to_add->zipname)) { $v_result = 1; return $v_result; } if (!is_file($this->zipname)) { $v_result = $this->privDuplicate($p_archive_to_add->zipname); return $v_result; } if (($v_result=$this->privOpenFd('rb')) != 1) { return $v_result; } $v_central_dir = array(); if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) { $this->privCloseFd(); return $v_result; } @rewind($this->zip_fd); if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1) { $this->privCloseFd(); return $v_result; } $v_central_dir_to_add = array(); if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1) { $this->privCloseFd(); $p_archive_to_add->privCloseFd(); return $v_result; } @rewind($p_archive_to_add->zip_fd); $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) { $this->privCloseFd(); $p_archive_to_add->privCloseFd(); PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode'); return PclZip::errorCode(); } $v_size = $v_central_dir['offset']; while ($v_size != 0) { $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); $v_buffer = fread($this->zip_fd, $v_read_size); @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); $v_size -= $v_read_size; } $v_size = $v_central_dir_to_add['offset']; while ($v_size != 0) { $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size); @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); $v_size -= $v_read_size; } $v_offset = @ftell($v_zip_temp_fd); $v_size = $v_central_dir['size']; while ($v_size != 0) { $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); $v_buffer = @fread($this->zip_fd, $v_read_size); @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); $v_size -= $v_read_size; } $v_size = $v_central_dir_to_add['size']; while ($v_size != 0) { $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size); @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); $v_size -= $v_read_size; } $v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment']; $v_size = @ftell($v_zip_temp_fd)-$v_offset; $v_swap = $this->zip_fd; $this->zip_fd = $v_zip_temp_fd; $v_zip_temp_fd = $v_swap; if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1) { $this->privCloseFd(); $p_archive_to_add->privCloseFd(); @fclose($v_zip_temp_fd); $this->zip_fd = null; unset($v_header_list); return $v_result; } $v_swap = $this->zip_fd; $this->zip_fd = $v_zip_temp_fd; $v_zip_temp_fd = $v_swap; $this->privCloseFd(); $p_archive_to_add->privCloseFd(); @fclose($v_zip_temp_fd); @unlink($this->zipname); PclZipUtilRename($v_zip_temp_name, $this->zipname); return $v_result; } function privDuplicate($p_archive_filename) { $v_result=1; if (!is_file($p_archive_filename)) { $v_result = 1; return $v_result; } if (($v_result=$this->privOpenFd('wb')) != 1) { return $v_result; } if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0) { $this->privCloseFd(); PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode'); return PclZip::errorCode(); } $v_size = filesize($p_archive_filename); while ($v_size != 0) { $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); $v_buffer = fread($v_zip_temp_fd, $v_read_size); @fwrite($this->zip_fd, $v_buffer, $v_read_size); $v_size -= $v_read_size; } $this->privCloseFd(); @fclose($v_zip_temp_fd); return $v_result; } function privErrorLog($p_error_code=0, $p_error_string='') { if (PCLZIP_ERROR_EXTERNAL == 1) { PclError($p_error_code, $p_error_string); } else { $this->error_code = $p_error_code; $this->error_string = $p_error_string; } } function privErrorReset() { if (PCLZIP_ERROR_EXTERNAL == 1) { PclErrorReset(); } else { $this->error_code = 0; $this->error_string = ''; } } function privDisableMagicQuotes() { $v_result=1; if ( (!function_exists("get_magic_quotes_runtime")) || (!function_exists("set_magic_quotes_runtime"))) { return $v_result; } if ($this->magic_quotes_status != -1) { return $v_result; } $this->magic_quotes_status = @get_magic_quotes_runtime(); if ($this->magic_quotes_status == 1) { @set_magic_quotes_runtime(0); } return $v_result; } function privSwapBackMagicQuotes() { $v_result=1; if ( (!function_exists("get_magic_quotes_runtime")) || (!function_exists("set_magic_quotes_runtime"))) { return $v_result; } if ($this->magic_quotes_status != -1) { return $v_result; } if ($this->magic_quotes_status == 1) { @set_magic_quotes_runtime($this->magic_quotes_status); } return $v_result; } } function PclZipUtilPathReduction($p_dir) { $v_result = ""; if ($p_dir != "") { $v_list = explode("/", $p_dir); $v_skip = 0; for ($i=sizeof($v_list)-1; $i>=0; $i--) { if ($v_list[$i] == ".") { } else if ($v_list[$i] == "..") { $v_skip++; } else if ($v_list[$i] == "") { if ($i == 0) { $v_result = "/".$v_result; if ($v_skip > 0) { $v_result = $p_dir; $v_skip = 0; } } else if ($i == (sizeof($v_list)-1)) { $v_result = $v_list[$i]; } else { } } else { if ($v_skip > 0) { $v_skip--; } else { $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:""); } } } if ($v_skip > 0) { while ($v_skip > 0) { $v_result = '../'.$v_result; $v_skip--; } } } return $v_result; } function PclZipUtilPathInclusion($p_dir, $p_path) { $v_result = 1; if ( ($p_dir == '.') || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) { $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1); } if ( ($p_path == '.') || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) { $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1); } $v_list_dir = explode("/", $p_dir); $v_list_dir_size = sizeof($v_list_dir); $v_list_path = explode("/", $p_path); $v_list_path_size = sizeof($v_list_path); $i = 0; $j = 0; while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) { if ($v_list_dir[$i] == '') { $i++; continue; } if ($v_list_path[$j] == '') { $j++; continue; } if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != '')) { $v_result = 0; } $i++; $j++; } if ($v_result) { while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++; while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++; if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) { $v_result = 2; } else if ($i < $v_list_dir_size) { $v_result = 0; } } return $v_result; } function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0) { $v_result = 1; if ($p_mode==0) { while ($p_size != 0) { $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); $v_buffer = @fread($p_src, $v_read_size); @fwrite($p_dest, $v_buffer, $v_read_size); $p_size -= $v_read_size; } } else if ($p_mode==1) { while ($p_size != 0) { $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); $v_buffer = @gzread($p_src, $v_read_size); @fwrite($p_dest, $v_buffer, $v_read_size); $p_size -= $v_read_size; } } else if ($p_mode==2) { while ($p_size != 0) { $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); $v_buffer = @fread($p_src, $v_read_size); @gzwrite($p_dest, $v_buffer, $v_read_size); $p_size -= $v_read_size; } } else if ($p_mode==3) { while ($p_size != 0) { $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); $v_buffer = @gzread($p_src, $v_read_size); @gzwrite($p_dest, $v_buffer, $v_read_size); $p_size -= $v_read_size; } } return $v_result; } function PclZipUtilRename($p_src, $p_dest) { $v_result = 1; if (!@rename($p_src, $p_dest)) { if (!@copy($p_src, $p_dest)) { $v_result = 0; } else if (!@unlink($p_src)) { $v_result = 0; } } return $v_result; } function PclZipUtilOptionText($p_option) { $v_list = get_defined_constants(); for (reset($v_list); $v_key = key($v_list); next($v_list)) { $v_prefix = substr($v_key, 0, 10); if (( ($v_prefix == 'PCLZIP_OPT') || ($v_prefix == 'PCLZIP_CB_') || ($v_prefix == 'PCLZIP_ATT')) && ($v_list[$v_key] == $p_option)) { return $v_key; } } $v_result = 'Unknown'; return $v_result; } function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true) { if (stristr(php_uname(), 'windows')) { if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) { $p_path = substr($p_path, $v_position+1); } if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) { $p_path = strtr($p_path, '\\', '/'); } } return $p_path; } ?>
diff --git a/fileadmin/perms.php b/fileadmin/perms.php
new file mode 100644
index 00000000..6d38ff10
--- /dev/null
+++ b/fileadmin/perms.php
@@ -0,0 +1,198 @@
+ 0000, "0100" => 0100, "0010" => 0010,
+ "0001" => 0001, "0200" => 0200, "0020" => 0020,
+ "0002" => 0002, "0300" => 0300, "0030" => 0030,
+ "0003" => 0003, "0400" => 0400, "0040" => 0040,
+ "0004" => 0004, "0500" => 0500, "0050" => 0050,
+ "0005" => 0005, "0600" => 0600, "0060" => 0060,
+ "0006" => 0006, "0700" => 0700, "0070" => 0070,
+ "0007" => 0007, "0100" => 0100, "0010" => 0010,
+ "0110" => 0110, "0011" => 0011, "0120" => 0120,
+ "0012" => 0012, "0130" => 0130, "0013" => 0013,
+ "0140" => 0140, "0014" => 0014, "0150" => 0150,
+ "0015" => 0015, "0160" => 0160, "0016" => 0016,
+ "0170" => 0170, "0017" => 0017, "0200" => 0200,
+ "0020" => 0020, "0210" => 0210, "0021" => 0021,
+ "0220" => 0220, "0022" => 0022, "0230" => 0230,
+ "0023" => 0023, "0240" => 0240, "0024" => 0024,
+ "0250" => 0250, "0025" => 0025, "0260" => 0260,
+ "0026" => 0026, "0270" => 0270, "0027" => 0027,
+ "0300" => 0300, "0030" => 0030, "0310" => 0310,
+ "0031" => 0031, "0320" => 0320, "0032" => 0032,
+ "0330" => 0330, "0033" => 0033, "0340" => 0340,
+ "0034" => 0034, "0350" => 0350, "0035" => 0035,
+ "0360" => 0360, "0036" => 0036, "0370" => 0370,
+ "0037" => 0037, "0400" => 0400, "0040" => 0040,
+ "0410" => 0410, "0041" => 0041, "0420" => 0420,
+ "0042" => 0042, "0430" => 0430, "0043" => 0043,
+ "0440" => 0440, "0044" => 0044, "0450" => 0450,
+ "0045" => 0045, "0460" => 0460, "0046" => 0046,
+ "0470" => 0470, "0047" => 0047, "0500" => 0500,
+ "0050" => 0050, "0510" => 0510, "0051" => 0051,
+ "0520" => 0520, "0052" => 0052, "0530" => 0530,
+ "0053" => 0053, "0540" => 0540, "0054" => 0054,
+ "0550" => 0550, "0055" => 0055, "0560" => 0560,
+ "0056" => 0056, "0570" => 0570, "0057" => 0057,
+ "0600" => 0600, "0060" => 0060, "0610" => 0610,
+ "0061" => 0061, "0620" => 0620, "0062" => 0062,
+ "0630" => 0630, "0063" => 0063, "0640" => 0640,
+ "0064" => 0064, "0650" => 0650, "0065" => 0065,
+ "0660" => 0660, "0066" => 0066, "0670" => 0670,
+ "0067" => 0067, "0700" => 0700, "0070" => 0070,
+ "0710" => 0710, "0071" => 0071, "0720" => 0720,
+ "0072" => 0072, "0730" => 0730, "0073" => 0073,
+ "0740" => 0740, "0074" => 0074, "0750" => 0750,
+ "0075" => 0075, "0760" => 0760, "0076" => 0076,
+ "0770" => 0770, "0077" => 0077, "0100" => 0100,
+ "0101" => 0101, "0102" => 0102, "0103" => 0103,
+ "0104" => 0104, "0105" => 0105, "0106" => 0106,
+ "0107" => 0107, "0110" => 0110, "0111" => 0111,
+ "0112" => 0112, "0113" => 0113, "0114" => 0114,
+ "0115" => 0115, "0116" => 0116, "0117" => 0117,
+ "0120" => 0120, "0121" => 0121, "0122" => 0122,
+ "0123" => 0123, "0124" => 0124, "0125" => 0125,
+ "0126" => 0126, "0127" => 0127, "0130" => 0130,
+ "0131" => 0131, "0132" => 0132, "0133" => 0133,
+ "0134" => 0134, "0135" => 0135, "0136" => 0136,
+ "0137" => 0137, "0140" => 0140, "0141" => 0141,
+ "0142" => 0142, "0143" => 0143, "0144" => 0144,
+ "0145" => 0145, "0146" => 0146, "0147" => 0147,
+ "0150" => 0150, "0151" => 0151, "0152" => 0152,
+ "0153" => 0153, "0154" => 0154, "0155" => 0155,
+ "0156" => 0156, "0157" => 0157, "0160" => 0160,
+ "0161" => 0161, "0162" => 0162, "0163" => 0163,
+ "0164" => 0164, "0165" => 0165, "0166" => 0166,
+ "0167" => 0167, "0170" => 0170, "0171" => 0171,
+ "0172" => 0172, "0173" => 0173, "0174" => 0174,
+ "0175" => 0175, "0176" => 0176, "0177" => 0177,
+ "0200" => 0200, "0201" => 0201, "0202" => 0202,
+ "0203" => 0203, "0204" => 0204, "0205" => 0205,
+ "0206" => 0206, "0207" => 0207, "0210" => 0210,
+ "0211" => 0211, "0212" => 0212, "0213" => 0213,
+ "0214" => 0214, "0215" => 0215, "0216" => 0216,
+ "0217" => 0217, "0220" => 0220, "0221" => 0221,
+ "0222" => 0222, "0223" => 0223, "0224" => 0224,
+ "0225" => 0225, "0226" => 0226, "0227" => 0227,
+ "0230" => 0230, "0231" => 0231, "0232" => 0232,
+ "0233" => 0233, "0234" => 0234, "0235" => 0235,
+ "0236" => 0236, "0237" => 0237, "0240" => 0240,
+ "0241" => 0241, "0242" => 0242, "0243" => 0243,
+ "0244" => 0244, "0245" => 0245, "0246" => 0246,
+ "0247" => 0247, "0250" => 0250, "0251" => 0251,
+ "0252" => 0252, "0253" => 0253, "0254" => 0254,
+ "0255" => 0255, "0256" => 0256, "0257" => 0257,
+ "0260" => 0260, "0261" => 0261, "0262" => 0262,
+ "0263" => 0263, "0264" => 0264, "0265" => 0265,
+ "0266" => 0266, "0267" => 0267, "0270" => 0270,
+ "0271" => 0271, "0272" => 0272, "0273" => 0273,
+ "0274" => 0274, "0275" => 0275, "0276" => 0276,
+ "0277" => 0277, "0300" => 0300, "0301" => 0301,
+ "0302" => 0302, "0303" => 0303, "0304" => 0304,
+ "0305" => 0305, "0306" => 0306, "0307" => 0307,
+ "0310" => 0310, "0311" => 0311, "0312" => 0312,
+ "0313" => 0313, "0314" => 0314, "0315" => 0315,
+ "0316" => 0316, "0317" => 0317, "0320" => 0320,
+ "0321" => 0321, "0322" => 0322, "0323" => 0323,
+ "0324" => 0324, "0325" => 0325, "0326" => 0326,
+ "0327" => 0327, "0330" => 0330, "0331" => 0331,
+ "0332" => 0332, "0333" => 0333, "0334" => 0334,
+ "0335" => 0335, "0336" => 0336, "0337" => 0337,
+ "0340" => 0340, "0341" => 0341, "0342" => 0342,
+ "0343" => 0343, "0344" => 0344, "0345" => 0345,
+ "0346" => 0346, "0347" => 0347, "0350" => 0350,
+ "0351" => 0351, "0352" => 0352, "0353" => 0353,
+ "0354" => 0354, "0355" => 0355, "0356" => 0356,
+ "0357" => 0357, "0360" => 0360, "0361" => 0361,
+ "0362" => 0362, "0363" => 0363, "0364" => 0364,
+ "0365" => 0365, "0366" => 0366, "0367" => 0367,
+ "0370" => 0370, "0371" => 0371, "0372" => 0372,
+ "0373" => 0373, "0374" => 0374, "0375" => 0375,
+ "0376" => 0376, "0377" => 0377, "0400" => 0400,
+ "0401" => 0401, "0402" => 0402, "0403" => 0403,
+ "0404" => 0404, "0405" => 0405, "0406" => 0406,
+ "0407" => 0407, "0410" => 0410, "0411" => 0411,
+ "0412" => 0412, "0413" => 0413, "0414" => 0414,
+ "0415" => 0415, "0416" => 0416, "0417" => 0417,
+ "0420" => 0420, "0421" => 0421, "0422" => 0422,
+ "0423" => 0423, "0424" => 0424, "0425" => 0425,
+ "0426" => 0426, "0427" => 0427, "0430" => 0430,
+ "0431" => 0431, "0432" => 0432, "0433" => 0433,
+ "0434" => 0434, "0435" => 0435, "0436" => 0436,
+ "0437" => 0437, "0440" => 0440, "0441" => 0441,
+ "0442" => 0442, "0443" => 0443, "0444" => 0444,
+ "0445" => 0445, "0446" => 0446, "0447" => 0447,
+ "0450" => 0450, "0451" => 0451, "0452" => 0452,
+ "0453" => 0453, "0454" => 0454, "0455" => 0455,
+ "0456" => 0456, "0457" => 0457, "0460" => 0460,
+ "0461" => 0461, "0462" => 0462, "0463" => 0463,
+ "0464" => 0464, "0465" => 0465, "0466" => 0466,
+ "0467" => 0467, "0470" => 0470, "0471" => 0471,
+ "0472" => 0472, "0473" => 0473, "0474" => 0474,
+ "0475" => 0475, "0476" => 0476, "0477" => 0477,
+ "0500" => 0500, "0501" => 0501, "0502" => 0502,
+ "0503" => 0503, "0504" => 0504, "0505" => 0505,
+ "0506" => 0506, "0507" => 0507, "0510" => 0510,
+ "0511" => 0511, "0512" => 0512, "0513" => 0513,
+ "0514" => 0514, "0515" => 0515, "0516" => 0516,
+ "0517" => 0517, "0520" => 0520, "0521" => 0521,
+ "0522" => 0522, "0523" => 0523, "0524" => 0524,
+ "0525" => 0525, "0526" => 0526, "0527" => 0527,
+ "0530" => 0530, "0531" => 0531, "0532" => 0532,
+ "0533" => 0533, "0534" => 0534, "0535" => 0535,
+ "0536" => 0536, "0537" => 0537, "0540" => 0540,
+ "0541" => 0541, "0542" => 0542, "0543" => 0543,
+ "0544" => 0544, "0545" => 0545, "0546" => 0546,
+ "0547" => 0547, "0550" => 0550, "0551" => 0551,
+ "0552" => 0552, "0553" => 0553, "0554" => 0554,
+ "0555" => 0555, "0556" => 0556, "0557" => 0557,
+ "0560" => 0560, "0561" => 0561, "0562" => 0562,
+ "0563" => 0563, "0564" => 0564, "0565" => 0565,
+ "0566" => 0566, "0567" => 0567, "0570" => 0570,
+ "0571" => 0571, "0572" => 0572, "0573" => 0573,
+ "0574" => 0574, "0575" => 0575, "0576" => 0576,
+ "0577" => 0577, "0600" => 0600, "0601" => 0601,
+ "0602" => 0602, "0603" => 0603, "0604" => 0604,
+ "0605" => 0605, "0606" => 0606, "0607" => 0607,
+ "0610" => 0610, "0611" => 0611, "0612" => 0612,
+ "0613" => 0613, "0614" => 0614, "0615" => 0615,
+ "0616" => 0616, "0617" => 0617, "0620" => 0620,
+ "0621" => 0621, "0622" => 0622, "0623" => 0623,
+ "0624" => 0624, "0625" => 0625, "0626" => 0626,
+ "0627" => 0627, "0630" => 0630, "0631" => 0631,
+ "0632" => 0632, "0633" => 0633, "0634" => 0634,
+ "0635" => 0635, "0636" => 0636, "0637" => 0637,
+ "0640" => 0640, "0641" => 0641, "0642" => 0642,
+ "0643" => 0643, "0644" => 0644, "0645" => 0645,
+ "0646" => 0646, "0647" => 0647, "0650" => 0650,
+ "0651" => 0651, "0652" => 0652, "0653" => 0653,
+ "0654" => 0654, "0655" => 0655, "0656" => 0656,
+ "0657" => 0657, "0660" => 0660, "0661" => 0661,
+ "0662" => 0662, "0663" => 0663, "0664" => 0664,
+ "0665" => 0665, "0666" => 0666, "0667" => 0667,
+ "0670" => 0670, "0671" => 0671, "0672" => 0672,
+ "0673" => 0673, "0674" => 0674, "0675" => 0675,
+ "0676" => 0676, "0677" => 0677, "0700" => 0700,
+ "0701" => 0701, "0702" => 0702, "0703" => 0703,
+ "0704" => 0704, "0705" => 0705, "0706" => 0706,
+ "0707" => 0707, "0710" => 0710, "0711" => 0711,
+ "0712" => 0712, "0713" => 0713, "0714" => 0714,
+ "0715" => 0715, "0716" => 0716, "0717" => 0717,
+ "0720" => 0720, "0721" => 0721, "0722" => 0722,
+ "0723" => 0723, "0724" => 0724, "0725" => 0725,
+ "0726" => 0726, "0727" => 0727, "0730" => 0730,
+ "0731" => 0731, "0732" => 0732, "0733" => 0733,
+ "0734" => 0734, "0735" => 0735, "0736" => 0736,
+ "0737" => 0737, "0740" => 0740, "0741" => 0741,
+ "0742" => 0742, "0743" => 0743, "0744" => 0744,
+ "0745" => 0745, "0746" => 0746, "0747" => 0747,
+ "0750" => 0750, "0751" => 0751, "0752" => 0752,
+ "0753" => 0753, "0754" => 0754, "0755" => 0755,
+ "0756" => 0756, "0757" => 0757, "0760" => 0760,
+ "0761" => 0761, "0762" => 0762, "0763" => 0763,
+ "0764" => 0764, "0765" => 0765, "0766" => 0766,
+ "0767" => 0767, "0770" => 0770, "0771" => 0771,
+ "0772" => 0772, "0773" => 0773, "0774" => 0774,
+ "0775" => 0775, "0776" => 0776, "0777" => 0777
+);
+?>
diff --git a/fileadmin/pkzip.php b/fileadmin/pkzip.php
new file mode 100644
index 00000000..c2426ccf
--- /dev/null
+++ b/fileadmin/pkzip.php
@@ -0,0 +1,28 @@
+\n";
+ echo "[返回 ]抱歉,文件清单为空!\n";
+ echo "\n";
+} else {
+ require "pclzip.php";
+ $pkzip = new pclzip($gopath = trim($_GET['gopath']));
+ echo "[目录 ]\n";
+ if ($pkzip->create($_SESSION['flist'], PCLZIP_OPT_REMOVE_PATH, dirname($gopath))) {
+ echo "文件 " . ___basename($gopath) . " 创建成功!";
+ } else {
+ echo "文件 " . ___basename($gopath) . " 无法建立!";
+ }
+}
+xhtml_footer();
+?>
diff --git a/fileadmin/readme.txt b/fileadmin/readme.txt
new file mode 100644
index 00000000..9cef02e4
--- /dev/null
+++ b/fileadmin/readme.txt
@@ -0,0 +1,72 @@
+----------------
+爱特网站文件专家
+----------------
+01.文件批量压缩功能
+02.批量网址获取文件
+03.文件批量上传功能
+04.强大权限设置支持
+05.批量文件删除功能
+06.批量文件复制支持
+07.批量文件移动支持
+08.批量建立目录文件
+09.高级终端命令执行
+10.批量文件传至邮箱
+11.实用文件清单支持
+12.自定编码查看文件
+13.自定编码编辑文件
+14.目录与文件的命名
+15.创建文件复件支持
+16.目录位置允许跳转
+17.文件效验Md5,Sha1
+18.硬盘使用情况查看
+19.任意文件下载支持
+20.牛逼强大解压支持
+21.文件编码转换工具
+22.下载文件断点续传
+----------------
+->>目前支持压缩类型
+Gz,Bz2,Zip
+->>目前支持解压类型
+Gz,Bz2,Tar,Tgz,Tbz,Zip
+----------------
+->>爱特文件专家安装
+环境:PHP5+ SESSION
+首次使用提示创建帐号密码
+修改密码直接编辑admin.php
+在Linux操作系统中将更好用
+不选择任何文件则使用清单文件
+选择文件并操作会清空文件清单
+编辑文件如不选择编码将用UTF-8
+->>爱特文件专家技巧
+文件列表添加Ftp://可以操作Ftp文件
+使用远程上传输入Url地址即可导入文件
+用清单功能批量操作不同目录文件,如压缩
+命名功能如果输入绝对路径还可以当移动使
+有时操作重要文件怕出错,文件复件让你安心
+谦容各种浏览器,甚至Elinks也能完美的使用
+更多技巧等你使用,欢迎Bug的反馈与交流讨论
+----------------
+-->爱特文件专家作者
+官方网站:aite.me
+腾讯扣群:38181604
+腾讯扣扣:88966001
+腾讯扣扣:759234755
+电子邮箱:admin@aite.me
+电子邮箱:xiaoqidun@gmail.com
+组件下载:http://aite.me/7zrar.zip
+官方更新:http://aite.me/fileadmin.zip
+----------------
+-->爱特文件专家版权
+爱特文件专家使用了Pclzip和Archive_Tar
+http://www.phpconcept.net/pclzip
+http://pear.php.net/package/Archive_Tar
+爱特文件专家除此库之外均为原创编码
+----------------
+如果解压选项中出现了rar和7za二个选项且是linux系统
+你可能需要安装爱特文件专家的unrar和p7zip组件才能用
+unrar和p7zip(x64\x86\arm)http://aite.me/7zrar.zip
+借助这二个强大的组件你可以用爱特文件管理器解压任意格式压缩包
+可以用文件管理器的远程下载直接导入unrar和p7zip组件包,然后在线解压
+解压后有x64\x86\arm三个目录,一般空间用x86,一般安卓手机环境用arm组件
+进入对应的组件目录,将p7zip.bin和unrar.bin文件移动到文件管理器目录即可
+然后文件管理器的rar和7za解压选项就可以用了,当然也可以解压带密码压缩包
diff --git a/fileadmin/rename.php b/fileadmin/rename.php
new file mode 100644
index 00000000..e2154ea2
--- /dev/null
+++ b/fileadmin/rename.php
@@ -0,0 +1,31 @@
+\n返回目录 \n新的命名\n";
+echo "\n";
+echo "\n";
+echo "
\n";
+xhtml_footer();
+?>
diff --git a/fileadmin/shell.php b/fileadmin/shell.php
new file mode 100644
index 00000000..37e04dbf
--- /dev/null
+++ b/fileadmin/shell.php
@@ -0,0 +1,69 @@
+\n";
+ echo "返回目录 错误提示\n";
+ echo "\n";
+ echo "\n";
+ echo "您没有打开SHELL权限!";
+ echo "
\n";
+ xhtml_footer();
+ exit;
+}
+chdir($getcwd);
+xhtml_head("SHELL");
+echo "\n";
+echo "
返回目录 SHELL\n";
+echo "
\n";
+echo "\n";
+echo "\n";
+echo "
\n";
+if (isset($_POST['shell'])) if (($s = trim($_POST['shell'])) != "") {
+ echo "\n结果返回SHELL\n
\n";
+ echo "\n";
+ if (function_exists("proc_open") && function_exists("stream_get_contents") && php_uname("s") == "Linux") {
+ if (!($sh = proc_open("sh", array(0 => array("pipe", "r"), 1 => array("pipe", "w")), $pipes))) {
+ echo "Open Shell Error !";
+ } else {
+ $i = 0;
+ $shell = explode("\n", $s);
+ while ($i < count($shell)) {
+ $x = trim($shell[$i]);
+ fwrite($pipes[0], "$x\n");
+ $i++;
+ }
+ fclose($pipes[0]);
+ $stream = stream_get_contents($pipes[1]);
+ if ($stream != "") {
+ echo "
" . nl2br(___codepre(trim($stream))) . " ";
+ } else {
+ echo "NULL";
+ }
+ fclose($pipes[1]);
+ proc_close($sh);
+ }
+ } else {
+ $i = 0;
+ $shell = explode("\n", $s);
+ while ($i < count($shell)) {
+ $sh = trim($shell[$i]);
+ echo "shell# $sh
\n";
+ echo nl2br(___codepre(shell_exec($sh))) . "\n";
+ $i++;
+ }
+ }
+ echo "
\n";
+}
+xhtml_footer();
+?>
diff --git a/fileadmin/style.css b/fileadmin/style.css
new file mode 100644
index 00000000..092b4a34
--- /dev/null
+++ b/fileadmin/style.css
@@ -0,0 +1,53 @@
+.like {
+ padding: 3px;
+ color: #000000;
+ font-size: 18px;
+ background-color: #00BFFF;
+ border-bottom: 3px solid #1E90FF;
+}
+
+.love {
+ padding: 2px;
+ color: #000000;
+ word-wrap: break-word;
+ border-left: 1px solid #B0E0B6;
+ border-right: 1px solid #B0E0B6;
+ border-bottom: 1px dotted #6495ED;
+}
+
+.error {
+ color: red;
+ padding: 2px;
+ word-wrap: break-word;
+ border: 1px solid red;
+}
+
+#header {
+ padding: 4px;
+ color: #000000;
+ font-size: 18px;
+ background-color: #3CB369;
+ border-top-left-radius: 8px;
+ border-top-right-radius: 8px;
+ border-bottom: 3px solid #008080;
+}
+
+#footer {
+ padding: 4px;
+ color: #000000;
+ font-size: 18px;
+ background-color: #3CB369;
+ border-bottom-left-radius: 8px;
+ border-bottom-right-radius: 8px;
+ border-bottom: 3px solid #008080;
+}
+
+#footer a:link {
+ color: #000000;
+ text-decoration: none;
+}
+
+#footer a:visited {
+ color: #000000;
+ text-decoration: none;
+}
diff --git a/fileadmin/system.php b/fileadmin/system.php
new file mode 100644
index 00000000..46856b57
--- /dev/null
+++ b/fileadmin/system.php
@@ -0,0 +1,203 @@
+ 1) {
+ $arr1 = array("&", "\"", "'", "<", ">", '"');
+ $arr2 = array("&", """, "'", "<", ">", "'");
+ } else {
+ $arr1 = array("&", "\"", "'", "<", ">", " ", '"');
+ $arr2 = array("&", """, "'", "<", ">", " ", "'");
+ }
+ return str_replace($arr1, $arr2, $str);
+}
+
+function ___ziplist()
+{
+ $zip = trim(func_get_arg(0));
+ if (!is_readable('pclzip.php') || !___getmime($zip, 'zip')) return false;
+ require 'pclzip.php';
+ $pclzip = new pclzip($zip);
+ if (!($getlist = $pclzip->listContent())) return false;
+ if (!is_array($getlist) || count($getlist) < 1) return false;
+ return $getlist;
+}
+
+function ___convert()
+{
+ $str = func_get_arg(0);
+ if (!function_exists("mb_convert_encoding")) return $str;
+ $encode = func_num_args() < 2 ? "UTF-8" : func_get_arg(1);
+ $enlist = func_num_args() > 2 ? func_get_arg(2) : "auto,CP936";
+ return mb_convert_encoding($str, $encode, $enlist);
+}
+
+function ___getmime()
+{
+ $path = trim(func_get_arg(0));
+ if (func_num_args() >= 2) {
+ $type = trim(func_get_arg(1));
+ $type = explode(':', $type);
+ }
+ if (!is_file($path)) return false;
+ if (!($fp = fopen($path, "rb"))) return false;
+ $bsupport = array(
+ array('jpg', 'ffd8ff', 'image/jpeg'),
+ array('png', '89504e47', 'image/png'),
+ array('gif', '47494638', 'image/gif'),
+ array('bmp', '424d', 'image/x-ms-bmp'),
+ array('zip', '504b0304', 'application/zip'));
+ $headstr = bin2hex(fread($fp, 4));
+ fclose($fp);
+ foreach ($bsupport as $temp) {
+ if (preg_match("/^$temp[1]/i", $headstr)) {
+ if (!isset($type)) {
+ return $temp[2];
+ } elseif (in_array($temp[0], $type)) {
+ return $temp[2];
+ }
+ }
+ }
+ return false;
+}
+
+function ___sendfile()
+{
+ $i = 0;
+ $to = func_get_arg(0);
+ $fs = func_get_arg(1);
+ if (!is_file("email.php")) {
+ return false;
+ } else {
+ require "email.php";
+ }
+ if ($to == "" || !is_array($fs)) {
+ return false;
+ } elseif (count($fs) < 1) {
+ return false;
+ }
+ $systags = uniqid("");
+ $subject = "your files";
+ $headers = "Content-Type: multipart/mixed; boundary=\"$systags\"\r\n";
+ $emailbody = "--$systags\r\n";
+ $emailbody .= "Content-type: text/plain; charset=utf-8\r\n";
+ $emailbody .= "Content-transfer-encoding: 8bit\r\n\r\n";
+ while ($i < count($fs)) {
+ if (!is_file($fs[$i]) || !is_readable($fs[$i])) continue;
+ $attachment = chunk_split(base64_encode(file_get_contents($fs[$i])));
+ $emailbody .= "--$systags\r\n";
+ $emailbody .= "Content-type: application/octet-stream; name=" . ___basename($fs[$i]) . "\r\n";
+ $emailbody .= "Content-transfer-encoding: base64\r\n\r\n";
+ $emailbody .= "$attachment\r\n\r\n";
+ $i++;
+ }
+ $emailbody .= "--$systags--";
+ return email($to, "from aite.me file manager", $emailbody, $headers);
+}
+
+function ___download()
+{
+ $path = trim(func_get_arg(0));
+ $size = filesize($path);
+ (isset($_SERVER['HTTP_RANGE']) && !empty($_SERVER['HTTP_RANGE']) && $range = substr($_SERVER['HTTP_RANGE'], 6)) || $range = '0-' . ($size - 1);
+ if (substr($range, -1) == '-') {
+ $init = substr($range, 0, -1);
+ $stop = $size - 1;
+ } elseif (substr($range, 0, 1) == '-') {
+ $init = $size - substr($range, 1) - 1;
+ $stop = $size - 1;
+ } else {
+ $init_stop = explode('-', $range);
+ $init = $init_stop[0];
+ $stop = $init_stop[1];
+ }
+ header('HTTP/1.1 206 Partial Content');
+ header('Accept-Ranges: bytes');
+ header('Content-Type: application/force-download');
+ header('Content-Disposition: attachment; filename=' . ___basename($path));
+ header("Content-Range: bytes $init-$stop/$size");
+ header('Content-Length: ' . ($stop - $init + 1));
+ $fp = fopen($path, "rb");
+ fseek($fp, $init);
+ while (!feof($fp)) {
+ echo fread($fp, 4096);
+ if (ftell($fp) > $stop) {
+ break;
+ }
+ }
+ fclose($fp);
+}
+
+function ___basename()
+{
+ $path = trim(func_get_arg(0));
+ $path = str_replace("\\", "/", $path);
+ $path = explode("/", $path);
+ return ___convert($path[count($path) - 1]);
+}
+
+function ___realpath()
+{
+ $path = func_get_arg(0);
+ $path = str_replace('\\', '/', $path);
+ if (!is_link($path)) return realpath($path);
+ return preg_replace('/[^:]?\/{2,}/si', '/', $path);
+}
+
+function ___filesize()
+{
+ $size = trim(func_get_arg(0));
+ if ($size < 1024) {
+ return $size . " B";
+ } elseif ($size < 1024 * 1024) {
+ return number_format($size / 1024, 3) . " KB";
+ } elseif ($size < 1024 * 1024 * 1024) {
+ return number_format($size / 1024 / 1024, 3) . " MB";
+ } elseif ($size < 1024 * 1024 * 1024 * 1024) {
+ return number_format($size / 1024 / 1024 / 1024, 3) . " GB";
+ } else {
+ return number_format($size / 1024 / 1024 / 1024 / 1024, 3) . " TB";
+ }
+}
+
+function ___superexec()
+{
+ $cmd = trim(func_get_arg(0));
+ if (php_uname("s") != "Linux") return false;
+ if ($cmd == "" || !function_exists("proc_open") || !function_exists("stream_get_contents")) {
+ return false;
+ }
+ if (!is_resource($sh = proc_open("exec sh", array(0 => array("pipe", "r"), 1 => array("pipe", "w")), $pipes))) {
+ return false;
+ }
+ fwrite($pipes[0], "export LANG=\"zh_CN.utf8\"\n");
+ fwrite($pipes[0], $cmd);
+ fclose($pipes[0]);
+ $result = stream_get_contents($pipes[1]);
+ fclose($pipes[1]);
+ proc_close($sh);
+ return trim($result);
+}
+
+function ___shortpath()
+{
+ $path = trim(func_get_arg(0));
+ $path = ___convert($path, "UTF-8");
+ if (function_exists('mb_strlen')) {
+ if (mb_strlen($path, "UTF-8") <= 18) return $path;
+ } else {
+ if (strlen($path) <= 18) return $path;
+ }
+ $path1 = function_exists('mb_substr') ? mb_substr($path, -9, 9, "UTF-8") : substr($path, -9);
+ $path2 = function_exists('mb_substr') ? mb_substr($path, 0, 9, "UTF-8") : substr($path, 0, 9);
+ return $path2 . " .... " . $path1;
+}
+
+?>
diff --git a/fileadmin/tarcls.php b/fileadmin/tarcls.php
new file mode 100644
index 00000000..b3bdb651
--- /dev/null
+++ b/fileadmin/tarcls.php
@@ -0,0 +1,2 @@
+ true, 'raiseError' => true, 'throwError' => true, 'pushErrorHandling' => true, 'popErrorHandling' => true, ); function __construct($error_class = null) { $classname = strtolower(get_class($this)); if ($this->_debug) { print "PEAR constructor called, class=$classname\n"; } if ($error_class !== null) { $this->_error_class = $error_class; } while ($classname && strcasecmp($classname, "pear")) { $destructor = "_$classname"; if (method_exists($this, $destructor)) { global $_PEAR_destructor_object_list; $_PEAR_destructor_object_list[] = &$this; if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) { register_shutdown_function("_PEAR_call_destructors"); $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true; } break; } else { $classname = get_parent_class($classname); } } } public function PEAR($error_class = null) { $this->__construct($error_class); } function _PEAR() { if ($this->_debug) { printf("PEAR destructor called, class=%s\n", strtolower(get_class($this))); } } public function __call($method, $arguments) { if (!isset(self::$bivalentMethods[$method])) { trigger_error( 'Call to undefined method PEAR::' . $method . '()', E_USER_ERROR ); } return call_user_func_array( array(get_class(), '_' . $method), array_merge(array($this), $arguments) ); } public static function __callStatic($method, $arguments) { if (!isset(self::$bivalentMethods[$method])) { trigger_error( 'Call to undefined method PEAR::' . $method . '()', E_USER_ERROR ); } return call_user_func_array( array(get_class(), '_' . $method), array_merge(array(null), $arguments) ); } public static function &getStaticProperty($class, $var) { static $properties; if (!isset($properties[$class])) { $properties[$class] = array(); } if (!array_key_exists($var, $properties[$class])) { $properties[$class][$var] = null; } return $properties[$class][$var]; } public static function registerShutdownFunc($func, $args = array()) { if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) { register_shutdown_function("_PEAR_call_destructors"); $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true; } $GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args); } public static function isError($data, $code = null) { if (!is_a($data, 'PEAR_Error')) { return false; } if (is_null($code)) { return true; } elseif (is_string($code)) { return $data->getMessage() == $code; } return $data->getCode() == $code; } protected static function _setErrorHandling( $object, $mode = null, $options = null ) { if ($object !== null) { $setmode = &$object->_default_error_mode; $setoptions = &$object->_default_error_options; } else { $setmode = &$GLOBALS['_PEAR_default_error_mode']; $setoptions = &$GLOBALS['_PEAR_default_error_options']; } switch ($mode) { case PEAR_ERROR_EXCEPTION: case PEAR_ERROR_RETURN: case PEAR_ERROR_PRINT: case PEAR_ERROR_TRIGGER: case PEAR_ERROR_DIE: case null: $setmode = $mode; $setoptions = $options; break; case PEAR_ERROR_CALLBACK: $setmode = $mode; if (is_callable($options)) { $setoptions = $options; } else { trigger_error("invalid error callback", E_USER_WARNING); } break; default: trigger_error("invalid error mode", E_USER_WARNING); break; } } function expectError($code = '*') { if (is_array($code)) { array_push($this->_expected_errors, $code); } else { array_push($this->_expected_errors, array($code)); } return count($this->_expected_errors); } function popExpect() { return array_pop($this->_expected_errors); } function _checkDelExpect($error_code) { $deleted = false; foreach ($this->_expected_errors as $key => $error_array) { if (in_array($error_code, $error_array)) { unset($this->_expected_errors[$key][array_search($error_code, $error_array)]); $deleted = true; } if (0 == count($this->_expected_errors[$key])) { unset($this->_expected_errors[$key]); } } return $deleted; } function delExpect($error_code) { $deleted = false; if ((is_array($error_code) && (0 != count($error_code)))) { foreach ($error_code as $key => $error) { $deleted = $this->_checkDelExpect($error) ? true : false; } return $deleted ? true : PEAR::raiseError("The expected error you submitted does not exist"); } elseif (!empty($error_code)) { if ($this->_checkDelExpect($error_code)) { return true; } return PEAR::raiseError("The expected error you submitted does not exist"); } return PEAR::raiseError("The expected error you submitted is empty"); } protected static function _raiseError($object, $message = null, $code = null, $mode = null, $options = null, $userinfo = null, $error_class = null, $skipmsg = false) { if (is_object($message)) { $code = $message->getCode(); $userinfo = $message->getUserInfo(); $error_class = $message->getType(); $message->error_message_prefix = ''; $message = $message->getMessage(); } if ( $object !== null && isset($object->_expected_errors) && count($object->_expected_errors) > 0 && count($exp = end($object->_expected_errors)) ) { if ($exp[0] == "*" || (is_int(reset($exp)) && in_array($code, $exp)) || (is_string(reset($exp)) && in_array($message, $exp)) ) { $mode = PEAR_ERROR_RETURN; } } if ($mode === null) { if ($object !== null && isset($object->_default_error_mode)) { $mode = $object->_default_error_mode; $options = $object->_default_error_options; } elseif (isset($GLOBALS['_PEAR_default_error_mode'])) { $mode = $GLOBALS['_PEAR_default_error_mode']; $options = $GLOBALS['_PEAR_default_error_options']; } } if ($error_class !== null) { $ec = $error_class; } elseif ($object !== null && isset($object->_error_class)) { $ec = $object->_error_class; } else { $ec = 'PEAR_Error'; } if ($skipmsg) { $a = new $ec($code, $mode, $options, $userinfo); } else { $a = new $ec($message, $code, $mode, $options, $userinfo); } return $a; } protected static function _throwError($object, $message = null, $code = null, $userinfo = null) { if ($object !== null) { $a = &$object->raiseError($message, $code, null, null, $userinfo); return $a; } $a = &PEAR::raiseError($message, $code, null, null, $userinfo); return $a; } public static function staticPushErrorHandling($mode, $options = null) { $stack = &$GLOBALS['_PEAR_error_handler_stack']; $def_mode = &$GLOBALS['_PEAR_default_error_mode']; $def_options = &$GLOBALS['_PEAR_default_error_options']; $stack[] = array($def_mode, $def_options); switch ($mode) { case PEAR_ERROR_EXCEPTION: case PEAR_ERROR_RETURN: case PEAR_ERROR_PRINT: case PEAR_ERROR_TRIGGER: case PEAR_ERROR_DIE: case null: $def_mode = $mode; $def_options = $options; break; case PEAR_ERROR_CALLBACK: $def_mode = $mode; if (is_callable($options)) { $def_options = $options; } else { trigger_error("invalid error callback", E_USER_WARNING); } break; default: trigger_error("invalid error mode", E_USER_WARNING); break; } $stack[] = array($mode, $options); return true; } public static function staticPopErrorHandling() { $stack = &$GLOBALS['_PEAR_error_handler_stack']; $setmode = &$GLOBALS['_PEAR_default_error_mode']; $setoptions = &$GLOBALS['_PEAR_default_error_options']; array_pop($stack); list($mode, $options) = $stack[sizeof($stack) - 1]; array_pop($stack); switch ($mode) { case PEAR_ERROR_EXCEPTION: case PEAR_ERROR_RETURN: case PEAR_ERROR_PRINT: case PEAR_ERROR_TRIGGER: case PEAR_ERROR_DIE: case null: $setmode = $mode; $setoptions = $options; break; case PEAR_ERROR_CALLBACK: $setmode = $mode; if (is_callable($options)) { $setoptions = $options; } else { trigger_error("invalid error callback", E_USER_WARNING); } break; default: trigger_error("invalid error mode", E_USER_WARNING); break; } return true; } protected static function _pushErrorHandling($object, $mode, $options = null) { $stack = &$GLOBALS['_PEAR_error_handler_stack']; if ($object !== null) { $def_mode = &$object->_default_error_mode; $def_options = &$object->_default_error_options; } else { $def_mode = &$GLOBALS['_PEAR_default_error_mode']; $def_options = &$GLOBALS['_PEAR_default_error_options']; } $stack[] = array($def_mode, $def_options); if ($object !== null) { $object->setErrorHandling($mode, $options); } else { PEAR::setErrorHandling($mode, $options); } $stack[] = array($mode, $options); return true; } protected static function _popErrorHandling($object) { $stack = &$GLOBALS['_PEAR_error_handler_stack']; array_pop($stack); list($mode, $options) = $stack[sizeof($stack) - 1]; array_pop($stack); if ($object !== null) { $object->setErrorHandling($mode, $options); } else { PEAR::setErrorHandling($mode, $options); } return true; } public static function loadExtension($ext) { if (extension_loaded($ext)) { return true; } if ( function_exists('dl') === false || ini_get('enable_dl') != 1 ) { return false; } if (OS_WINDOWS) { $suffix = '.dll'; } elseif (PHP_OS == 'HP-UX') { $suffix = '.sl'; } elseif (PHP_OS == 'AIX') { $suffix = '.a'; } elseif (PHP_OS == 'OSX') { $suffix = '.bundle'; } else { $suffix = '.so'; } return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix); } } function _PEAR_call_destructors() { global $_PEAR_destructor_object_list; if (is_array($_PEAR_destructor_object_list) && sizeof($_PEAR_destructor_object_list)) { reset($_PEAR_destructor_object_list); $destructLifoExists = PEAR::getStaticProperty('PEAR', 'destructlifo'); if ($destructLifoExists) { $_PEAR_destructor_object_list = array_reverse($_PEAR_destructor_object_list); } while (list($k, $objref) = each($_PEAR_destructor_object_list)) { $classname = get_class($objref); while ($classname) { $destructor = "_$classname"; if (method_exists($objref, $destructor)) { $objref->$destructor(); break; } else { $classname = get_parent_class($classname); } } } $_PEAR_destructor_object_list = array(); } if ( isset($GLOBALS['_PEAR_shutdown_funcs']) && is_array($GLOBALS['_PEAR_shutdown_funcs']) && !empty($GLOBALS['_PEAR_shutdown_funcs']) ) { foreach ($GLOBALS['_PEAR_shutdown_funcs'] as $value) { call_user_func_array($value[0], $value[1]); } } } class PEAR_Error { var $error_message_prefix = ''; var $mode = PEAR_ERROR_RETURN; var $level = E_USER_NOTICE; var $code = -1; var $message = ''; var $userinfo = ''; var $backtrace = null; function __construct($message = 'unknown error', $code = null, $mode = null, $options = null, $userinfo = null) { if ($mode === null) { $mode = PEAR_ERROR_RETURN; } $this->message = $message; $this->code = $code; $this->mode = $mode; $this->userinfo = $userinfo; $skiptrace = PEAR::getStaticProperty('PEAR_Error', 'skiptrace'); if (!$skiptrace) { $this->backtrace = debug_backtrace(); if (isset($this->backtrace[0]) && isset($this->backtrace[0]['object'])) { unset($this->backtrace[0]['object']); } } if ($mode & PEAR_ERROR_CALLBACK) { $this->level = E_USER_NOTICE; $this->callback = $options; } else { if ($options === null) { $options = E_USER_NOTICE; } $this->level = $options; $this->callback = null; } if ($this->mode & PEAR_ERROR_PRINT) { if (is_null($options) || is_int($options)) { $format = "%s"; } else { $format = $options; } printf($format, $this->getMessage()); } if ($this->mode & PEAR_ERROR_TRIGGER) { trigger_error($this->getMessage(), $this->level); } if ($this->mode & PEAR_ERROR_DIE) { $msg = $this->getMessage(); if (is_null($options) || is_int($options)) { $format = "%s"; if (substr($msg, -1) != "\n") { $msg .= "\n"; } } else { $format = $options; } die(sprintf($format, $msg)); } if ($this->mode & PEAR_ERROR_CALLBACK && is_callable($this->callback)) { call_user_func($this->callback, $this); } if ($this->mode & PEAR_ERROR_EXCEPTION) { trigger_error("PEAR_ERROR_EXCEPTION is obsolete, use class PEAR_Exception for exceptions", E_USER_WARNING); eval('$e = new Exception($this->message, $this->code);throw($e);'); } } function getMode() { return $this->mode; } function getCallback() { return $this->callback; } function getMessage() { return ($this->error_message_prefix . $this->message); } function getCode() { return $this->code; } function getType() { return get_class($this); } function getUserInfo() { return $this->userinfo; } function getDebugInfo() { return $this->getUserInfo(); } function getBacktrace($frame = null) { if (defined('PEAR_IGNORE_BACKTRACE')) { return null; } if ($frame === null) { return $this->backtrace; } return $this->backtrace[$frame]; } function addUserInfo($info) { if (empty($this->userinfo)) { $this->userinfo = $info; } else { $this->userinfo .= " ** $info"; } } function __toString() { return $this->getMessage(); } function toString() { $modes = array(); $levels = array(E_USER_NOTICE => 'notice', E_USER_WARNING => 'warning', E_USER_ERROR => 'error'); if ($this->mode & PEAR_ERROR_CALLBACK) { if (is_array($this->callback)) { $callback = (is_object($this->callback[0]) ? strtolower(get_class($this->callback[0])) : $this->callback[0]) . '::' . $this->callback[1]; } else { $callback = $this->callback; } return sprintf('[%s: message="%s" code=%d mode=callback '. 'callback=%s prefix="%s" info="%s"]', strtolower(get_class($this)), $this->message, $this->code, $callback, $this->error_message_prefix, $this->userinfo); } if ($this->mode & PEAR_ERROR_PRINT) { $modes[] = 'print'; } if ($this->mode & PEAR_ERROR_TRIGGER) { $modes[] = 'trigger'; } if ($this->mode & PEAR_ERROR_DIE) { $modes[] = 'die'; } if ($this->mode & PEAR_ERROR_RETURN) { $modes[] = 'return'; } return sprintf('[%s: message="%s" code=%d mode=%s level=%s '. 'prefix="%s" info="%s"]', strtolower(get_class($this)), $this->message, $this->code, implode("|", $modes), $levels[$this->level], $this->error_message_prefix, $this->userinfo); } } define('ARCHIVE_TAR_ATT_SEPARATOR', 90001); define('ARCHIVE_TAR_END_BLOCK', pack("a512", '')); if (!function_exists('gzopen') && function_exists('gzopen64')) { function gzopen($filename, $mode, $use_include_path = 0) { return gzopen64($filename, $mode, $use_include_path); } } if (!function_exists('gztell') && function_exists('gztell64')) { function gztell($zp) { return gztell64($zp); } } if (!function_exists('gzseek') && function_exists('gzseek64')) { function gzseek($zp, $offset, $whence = SEEK_SET) { return gzseek64($zp, $offset, $whence); } } class Archive_Tar extends PEAR { public $_tarname = ''; public $_compress = false; public $_compress_type = 'none'; public $_separator = ' '; public $_file = 0; public $_temp_tarname = ''; public $_ignore_regexp = ''; public $error_object = null; public function __construct($p_tarname, $p_compress = null) { parent::__construct(); $this->_compress = false; $this->_compress_type = 'none'; if (($p_compress === null) || ($p_compress == '')) { if (@file_exists($p_tarname)) { if ($fp = @fopen($p_tarname, "rb")) { $data = fread($fp, 2); fclose($fp); if ($data == "\37\213") { $this->_compress = true; $this->_compress_type = 'gz'; } elseif ($data == "BZ") { $this->_compress = true; $this->_compress_type = 'bz2'; } elseif (file_get_contents($p_tarname, false, null, 1, 4) == '7zXZ') { $this->_compress = true; $this->_compress_type = 'lzma2'; } } } else { if (substr($p_tarname, -2) == 'gz') { $this->_compress = true; $this->_compress_type = 'gz'; } elseif ((substr($p_tarname, -3) == 'bz2') || (substr($p_tarname, -2) == 'bz') ) { $this->_compress = true; $this->_compress_type = 'bz2'; } else { if (substr($p_tarname, -2) == 'xz') { $this->_compress = true; $this->_compress_type = 'lzma2'; } } } } else { if (($p_compress === true) || ($p_compress == 'gz')) { $this->_compress = true; $this->_compress_type = 'gz'; } else { if ($p_compress == 'bz2') { $this->_compress = true; $this->_compress_type = 'bz2'; } else { if ($p_compress == 'lzma2') { $this->_compress = true; $this->_compress_type = 'lzma2'; } else { $this->_error( "Unsupported compression type '$p_compress'\n" . "Supported types are 'gz', 'bz2' and 'lzma2'.\n" ); return false; } } } } $this->_tarname = $p_tarname; if ($this->_compress) { if ($this->_compress_type == 'gz') { $extname = 'zlib'; } else { if ($this->_compress_type == 'bz2') { $extname = 'bz2'; } else { if ($this->_compress_type == 'lzma2') { $extname = 'xz'; } } } if (!extension_loaded($extname)) { PEAR::loadExtension($extname); } if (!extension_loaded($extname)) { $this->_error( "The extension '$extname' couldn't be found.\n" . "Please make sure your version of PHP was built " . "with '$extname' support.\n" ); return false; } } } public function __destruct() { $this->_close(); if ($this->_temp_tarname != '') { @unlink($this->_temp_tarname); } } public function create($p_filelist) { return $this->createModify($p_filelist, '', ''); } public function add($p_filelist) { return $this->addModify($p_filelist, '', ''); } public function extract($p_path = '', $p_preserve = false) { return $this->extractModify($p_path, '', $p_preserve); } public function listContent() { $v_list_detail = array(); if ($this->_openRead()) { if (!$this->_extractList('', $v_list_detail, "list", '', '')) { unset($v_list_detail); $v_list_detail = 0; } $this->_close(); } return $v_list_detail; } public function createModify($p_filelist, $p_add_dir, $p_remove_dir = '') { $v_result = true; if (!$this->_openWrite()) { return false; } if ($p_filelist != '') { if (is_array($p_filelist)) { $v_list = $p_filelist; } elseif (is_string($p_filelist)) { $v_list = explode($this->_separator, $p_filelist); } else { $this->_cleanFile(); $this->_error('Invalid file list'); return false; } $v_result = $this->_addList($v_list, $p_add_dir, $p_remove_dir); } if ($v_result) { $this->_writeFooter(); $this->_close(); } else { $this->_cleanFile(); } return $v_result; } public function addModify($p_filelist, $p_add_dir, $p_remove_dir = '') { $v_result = true; if (!$this->_isArchive()) { $v_result = $this->createModify( $p_filelist, $p_add_dir, $p_remove_dir ); } else { if (is_array($p_filelist)) { $v_list = $p_filelist; } elseif (is_string($p_filelist)) { $v_list = explode($this->_separator, $p_filelist); } else { $this->_error('Invalid file list'); return false; } $v_result = $this->_append($v_list, $p_add_dir, $p_remove_dir); } return $v_result; } public function addString($p_filename, $p_string, $p_datetime = false, $p_params = array()) { $p_stamp = @$p_params["stamp"] ? $p_params["stamp"] : ($p_datetime ? $p_datetime : time()); $p_mode = @$p_params["mode"] ? $p_params["mode"] : 0600; $p_type = @$p_params["type"] ? $p_params["type"] : ""; $p_uid = @$p_params["uid"] ? $p_params["uid"] : ""; $p_gid = @$p_params["gid"] ? $p_params["gid"] : ""; $v_result = true; if (!$this->_isArchive()) { if (!$this->_openWrite()) { return false; } $this->_close(); } if (!$this->_openAppend()) { return false; } $v_result = $this->_addString($p_filename, $p_string, $p_datetime, $p_params); $this->_writeFooter(); $this->_close(); return $v_result; } public function extractModify($p_path, $p_remove_path, $p_preserve = false) { $v_result = true; $v_list_detail = array(); if ($v_result = $this->_openRead()) { $v_result = $this->_extractList( $p_path, $v_list_detail, "complete", 0, $p_remove_path, $p_preserve ); $this->_close(); } return $v_result; } public function extractInString($p_filename) { if ($this->_openRead()) { $v_result = $this->_extractInString($p_filename); $this->_close(); } else { $v_result = null; } return $v_result; } public function extractList($p_filelist, $p_path = '', $p_remove_path = '', $p_preserve = false) { $v_result = true; $v_list_detail = array(); if (is_array($p_filelist)) { $v_list = $p_filelist; } elseif (is_string($p_filelist)) { $v_list = explode($this->_separator, $p_filelist); } else { $this->_error('Invalid string list'); return false; } if ($v_result = $this->_openRead()) { $v_result = $this->_extractList( $p_path, $v_list_detail, "partial", $v_list, $p_remove_path, $p_preserve ); $this->_close(); } return $v_result; } public function setAttribute() { $v_result = true; if (($v_size = func_num_args()) == 0) { return true; } $v_att_list = & func_get_args(); $i = 0; while ($i < $v_size) { switch ($v_att_list[$i]) { case ARCHIVE_TAR_ATT_SEPARATOR : if (($i + 1) >= $v_size) { $this->_error( 'Invalid number of parameters for ' . 'attribute ARCHIVE_TAR_ATT_SEPARATOR' ); return false; } $this->_separator = $v_att_list[$i + 1]; $i++; break; default : $this->_error('Unknown attribute code ' . $v_att_list[$i] . ''); return false; } $i++; } return $v_result; } public function setIgnoreRegexp($regexp) { $this->_ignore_regexp = $regexp; } public function setIgnoreList($list) { $regexp = str_replace(array('#', '.', '^', '$'), array('\#', '\.', '\^', '\$'), $list); $regexp = '#/' . join('$|/', $list) . '#'; $this->setIgnoreRegexp($regexp); } public function _error($p_message) { $this->error_object = $this->raiseError($p_message); } public function _warning($p_message) { $this->error_object = $this->raiseError($p_message); } public function _isArchive($p_filename = null) { if ($p_filename == null) { $p_filename = $this->_tarname; } clearstatcache(); return @is_file($p_filename) && !@is_link($p_filename); } public function _openWrite() { if ($this->_compress_type == 'gz' && function_exists('gzopen')) { $this->_file = @gzopen($this->_tarname, "wb9"); } else { if ($this->_compress_type == 'bz2' && function_exists('bzopen')) { $this->_file = @bzopen($this->_tarname, "w"); } else { if ($this->_compress_type == 'lzma2' && function_exists('xzopen')) { $this->_file = @xzopen($this->_tarname, 'w'); } else { if ($this->_compress_type == 'none') { $this->_file = @fopen($this->_tarname, "wb"); } else { $this->_error( 'Unknown or missing compression type (' . $this->_compress_type . ')' ); return false; } } } } if ($this->_file == 0) { $this->_error( 'Unable to open in write mode \'' . $this->_tarname . '\'' ); return false; } return true; } public function _openRead() { if (strtolower(substr($this->_tarname, 0, 7)) == 'http://') { if ($this->_temp_tarname == '') { $this->_temp_tarname = uniqid('tar') . '.tmp'; if (!$v_file_from = @fopen($this->_tarname, 'rb')) { $this->_error( 'Unable to open in read mode \'' . $this->_tarname . '\'' ); $this->_temp_tarname = ''; return false; } if (!$v_file_to = @fopen($this->_temp_tarname, 'wb')) { $this->_error( 'Unable to open in write mode \'' . $this->_temp_tarname . '\'' ); $this->_temp_tarname = ''; return false; } while ($v_data = @fread($v_file_from, 1024)) { @fwrite($v_file_to, $v_data); } @fclose($v_file_from); @fclose($v_file_to); } $v_filename = $this->_temp_tarname; } else { $v_filename = $this->_tarname; } if ($this->_compress_type == 'gz' && function_exists('gzopen')) { $this->_file = @gzopen($v_filename, "rb"); } else { if ($this->_compress_type == 'bz2' && function_exists('bzopen')) { $this->_file = @bzopen($v_filename, "r"); } else { if ($this->_compress_type == 'lzma2' && function_exists('xzopen')) { $this->_file = @xzopen($v_filename, "r"); } else { if ($this->_compress_type == 'none') { $this->_file = @fopen($v_filename, "rb"); } else { $this->_error( 'Unknown or missing compression type (' . $this->_compress_type . ')' ); return false; } } } } if ($this->_file == 0) { $this->_error('Unable to open in read mode \'' . $v_filename . '\''); return false; } return true; } public function _openReadWrite() { if ($this->_compress_type == 'gz') { $this->_file = @gzopen($this->_tarname, "r+b"); } else { if ($this->_compress_type == 'bz2') { $this->_error( 'Unable to open bz2 in read/write mode \'' . $this->_tarname . '\' (limitation of bz2 extension)' ); return false; } else { if ($this->_compress_type == 'lzma2') { $this->_error( 'Unable to open lzma2 in read/write mode \'' . $this->_tarname . '\' (limitation of lzma2 extension)' ); return false; } else { if ($this->_compress_type == 'none') { $this->_file = @fopen($this->_tarname, "r+b"); } else { $this->_error( 'Unknown or missing compression type (' . $this->_compress_type . ')' ); return false; } } } } if ($this->_file == 0) { $this->_error( 'Unable to open in read/write mode \'' . $this->_tarname . '\'' ); return false; } return true; } public function _close() { if (is_resource($this->_file)) { if ($this->_compress_type == 'gz') { @gzclose($this->_file); } else { if ($this->_compress_type == 'bz2') { @bzclose($this->_file); } else { if ($this->_compress_type == 'lzma2') { @xzclose($this->_file); } else { if ($this->_compress_type == 'none') { @fclose($this->_file); } else { $this->_error( 'Unknown or missing compression type (' . $this->_compress_type . ')' ); } } } } $this->_file = 0; } if ($this->_temp_tarname != '') { @unlink($this->_temp_tarname); $this->_temp_tarname = ''; } return true; } public function _cleanFile() { $this->_close(); if ($this->_temp_tarname != '') { @unlink($this->_temp_tarname); $this->_temp_tarname = ''; } else { @unlink($this->_tarname); } $this->_tarname = ''; return true; } public function _writeBlock($p_binary_data, $p_len = null) { if (is_resource($this->_file)) { if ($p_len === null) { if ($this->_compress_type == 'gz') { @gzputs($this->_file, $p_binary_data); } else { if ($this->_compress_type == 'bz2') { @bzwrite($this->_file, $p_binary_data); } else { if ($this->_compress_type == 'lzma2') { @xzwrite($this->_file, $p_binary_data); } else { if ($this->_compress_type == 'none') { @fputs($this->_file, $p_binary_data); } else { $this->_error( 'Unknown or missing compression type (' . $this->_compress_type . ')' ); } } } } } else { if ($this->_compress_type == 'gz') { @gzputs($this->_file, $p_binary_data, $p_len); } else { if ($this->_compress_type == 'bz2') { @bzwrite($this->_file, $p_binary_data, $p_len); } else { if ($this->_compress_type == 'lzma2') { @xzwrite($this->_file, $p_binary_data, $p_len); } else { if ($this->_compress_type == 'none') { @fputs($this->_file, $p_binary_data, $p_len); } else { $this->_error( 'Unknown or missing compression type (' . $this->_compress_type . ')' ); } } } } } } return true; } public function _readBlock() { $v_block = null; if (is_resource($this->_file)) { if ($this->_compress_type == 'gz') { $v_block = @gzread($this->_file, 512); } else { if ($this->_compress_type == 'bz2') { $v_block = @bzread($this->_file, 512); } else { if ($this->_compress_type == 'lzma2') { $v_block = @xzread($this->_file, 512); } else { if ($this->_compress_type == 'none') { $v_block = @fread($this->_file, 512); } else { $this->_error( 'Unknown or missing compression type (' . $this->_compress_type . ')' ); } } } } } return $v_block; } public function _jumpBlock($p_len = null) { if (is_resource($this->_file)) { if ($p_len === null) { $p_len = 1; } if ($this->_compress_type == 'gz') { @gzseek($this->_file, gztell($this->_file) + ($p_len * 512)); } else { if ($this->_compress_type == 'bz2') { for ($i = 0; $i < $p_len; $i++) { $this->_readBlock(); } } else { if ($this->_compress_type == 'lzma2') { for ($i = 0; $i < $p_len; $i++) { $this->_readBlock(); } } else { if ($this->_compress_type == 'none') { @fseek($this->_file, $p_len * 512, SEEK_CUR); } else { $this->_error( 'Unknown or missing compression type (' . $this->_compress_type . ')' ); } } } } } return true; } public function _writeFooter() { if (is_resource($this->_file)) { $v_binary_data = pack('a1024', ''); $this->_writeBlock($v_binary_data); } return true; } public function _addList($p_list, $p_add_dir, $p_remove_dir) { $v_result = true; $v_header = array(); $p_add_dir = $this->_translateWinPath($p_add_dir); $p_remove_dir = $this->_translateWinPath($p_remove_dir, false); if (!$this->_file) { $this->_error('Invalid file descriptor'); return false; } if (sizeof($p_list) == 0) { return true; } foreach ($p_list as $v_filename) { if (!$v_result) { break; } if ($v_filename == $this->_tarname) { continue; } if ($v_filename == '') { continue; } if ($this->_ignore_regexp && preg_match($this->_ignore_regexp, '/' . $v_filename)) { $this->_warning("File '$v_filename' ignored"); continue; } if (!file_exists($v_filename) && !is_link($v_filename)) { $this->_warning("File '$v_filename' does not exist"); continue; } if (!$this->_addFile($v_filename, $v_header, $p_add_dir, $p_remove_dir)) { return false; } if (@is_dir($v_filename) && !@is_link($v_filename)) { if (!($p_hdir = opendir($v_filename))) { $this->_warning("Directory '$v_filename' can not be read"); continue; } while (false !== ($p_hitem = readdir($p_hdir))) { if (($p_hitem != '.') && ($p_hitem != '..')) { if ($v_filename != ".") { $p_temp_list[0] = $v_filename . '/' . $p_hitem; } else { $p_temp_list[0] = $p_hitem; } $v_result = $this->_addList( $p_temp_list, $p_add_dir, $p_remove_dir ); } } unset($p_temp_list); unset($p_hdir); unset($p_hitem); } } return $v_result; } public function _addFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir, $v_stored_filename = null) { if (!$this->_file) { $this->_error('Invalid file descriptor'); return false; } if ($p_filename == '') { $this->_error('Invalid file name'); return false; } if (is_null($v_stored_filename)) { $p_filename = $this->_translateWinPath($p_filename, false); $v_stored_filename = $p_filename; if (strcmp($p_filename, $p_remove_dir) == 0) { return true; } if ($p_remove_dir != '') { if (substr($p_remove_dir, -1) != '/') { $p_remove_dir .= '/'; } if (substr($p_filename, 0, strlen($p_remove_dir)) == $p_remove_dir) { $v_stored_filename = substr($p_filename, strlen($p_remove_dir)); } } $v_stored_filename = $this->_translateWinPath($v_stored_filename); if ($p_add_dir != '') { if (substr($p_add_dir, -1) == '/') { $v_stored_filename = $p_add_dir . $v_stored_filename; } else { $v_stored_filename = $p_add_dir . '/' . $v_stored_filename; } } $v_stored_filename = $this->_pathReduction($v_stored_filename); } if ($this->_isArchive($p_filename)) { if (($v_file = @fopen($p_filename, "rb")) == 0) { $this->_warning( "Unable to open file '" . $p_filename . "' in binary read mode" ); return true; } if (!$this->_writeHeader($p_filename, $v_stored_filename)) { return false; } while (($v_buffer = fread($v_file, 512)) != '') { $v_binary_data = pack("a512", "$v_buffer"); $this->_writeBlock($v_binary_data); } fclose($v_file); } else { if (!$this->_writeHeader($p_filename, $v_stored_filename)) { return false; } } return true; } public function _addString($p_filename, $p_string, $p_datetime = false, $p_params = array()) { $p_stamp = @$p_params["stamp"] ? $p_params["stamp"] : ($p_datetime ? $p_datetime : time()); $p_mode = @$p_params["mode"] ? $p_params["mode"] : 0600; $p_type = @$p_params["type"] ? $p_params["type"] : ""; $p_uid = @$p_params["uid"] ? $p_params["uid"] : 0; $p_gid = @$p_params["gid"] ? $p_params["gid"] : 0; if (!$this->_file) { $this->_error('Invalid file descriptor'); return false; } if ($p_filename == '') { $this->_error('Invalid file name'); return false; } $p_filename = $this->_translateWinPath($p_filename, false); if ($p_datetime === false) { $p_datetime = time(); } if (!$this->_writeHeaderBlock( $p_filename, strlen($p_string), $p_stamp, $p_mode, $p_type, $p_uid, $p_gid ) ) { return false; } $i = 0; while (($v_buffer = substr($p_string, (($i++) * 512), 512)) != '') { $v_binary_data = pack("a512", $v_buffer); $this->_writeBlock($v_binary_data); } return true; } public function _writeHeader($p_filename, $p_stored_filename) { if ($p_stored_filename == '') { $p_stored_filename = $p_filename; } $v_reduce_filename = $this->_pathReduction($p_stored_filename); if (strlen($v_reduce_filename) > 99) { if (!$this->_writeLongHeader($v_reduce_filename)) { return false; } } $v_info = lstat($p_filename); $v_uid = sprintf("%07s", DecOct($v_info[4])); $v_gid = sprintf("%07s", DecOct($v_info[5])); $v_perms = sprintf("%07s", DecOct($v_info['mode'] & 000777)); $v_mtime = sprintf("%011s", DecOct($v_info['mtime'])); $v_linkname = ''; if (@is_link($p_filename)) { $v_typeflag = '2'; $v_linkname = readlink($p_filename); $v_size = sprintf("%011s", DecOct(0)); } elseif (@is_dir($p_filename)) { $v_typeflag = "5"; $v_size = sprintf("%011s", DecOct(0)); } else { $v_typeflag = '0'; clearstatcache(); $v_size = sprintf("%011s", DecOct($v_info['size'])); } $v_magic = 'ustar '; $v_version = ' '; if (function_exists('posix_getpwuid')) { $userinfo = posix_getpwuid($v_info[4]); $groupinfo = posix_getgrgid($v_info[5]); $v_uname = $userinfo['name']; $v_gname = $groupinfo['name']; } else { $v_uname = ''; $v_gname = ''; } $v_devmajor = ''; $v_devminor = ''; $v_prefix = ''; $v_binary_data_first = pack( "a100a8a8a8a12a12", $v_reduce_filename, $v_perms, $v_uid, $v_gid, $v_size, $v_mtime ); $v_binary_data_last = pack( "a1a100a6a2a32a32a8a8a155a12", $v_typeflag, $v_linkname, $v_magic, $v_version, $v_uname, $v_gname, $v_devmajor, $v_devminor, $v_prefix, '' ); $v_checksum = 0; for ($i = 0; $i < 148; $i++) { $v_checksum += ord(substr($v_binary_data_first, $i, 1)); } for ($i = 148; $i < 156; $i++) { $v_checksum += ord(' '); } for ($i = 156, $j = 0; $i < 512; $i++, $j++) { $v_checksum += ord(substr($v_binary_data_last, $j, 1)); } $this->_writeBlock($v_binary_data_first, 148); $v_checksum = sprintf("%06s ", DecOct($v_checksum)); $v_binary_data = pack("a8", $v_checksum); $this->_writeBlock($v_binary_data, 8); $this->_writeBlock($v_binary_data_last, 356); return true; } public function _writeHeaderBlock( $p_filename, $p_size, $p_mtime = 0, $p_perms = 0, $p_type = '', $p_uid = 0, $p_gid = 0 ) { $p_filename = $this->_pathReduction($p_filename); if (strlen($p_filename) > 99) { if (!$this->_writeLongHeader($p_filename)) { return false; } } if ($p_type == "5") { $v_size = sprintf("%011s", DecOct(0)); } else { $v_size = sprintf("%011s", DecOct($p_size)); } $v_uid = sprintf("%07s", DecOct($p_uid)); $v_gid = sprintf("%07s", DecOct($p_gid)); $v_perms = sprintf("%07s", DecOct($p_perms & 000777)); $v_mtime = sprintf("%11s", DecOct($p_mtime)); $v_linkname = ''; $v_magic = 'ustar '; $v_version = ' '; if (function_exists('posix_getpwuid')) { $userinfo = posix_getpwuid($p_uid); $groupinfo = posix_getgrgid($p_gid); $v_uname = $userinfo['name']; $v_gname = $groupinfo['name']; } else { $v_uname = ''; $v_gname = ''; } $v_devmajor = ''; $v_devminor = ''; $v_prefix = ''; $v_binary_data_first = pack( "a100a8a8a8a12A12", $p_filename, $v_perms, $v_uid, $v_gid, $v_size, $v_mtime ); $v_binary_data_last = pack( "a1a100a6a2a32a32a8a8a155a12", $p_type, $v_linkname, $v_magic, $v_version, $v_uname, $v_gname, $v_devmajor, $v_devminor, $v_prefix, '' ); $v_checksum = 0; for ($i = 0; $i < 148; $i++) { $v_checksum += ord(substr($v_binary_data_first, $i, 1)); } for ($i = 148; $i < 156; $i++) { $v_checksum += ord(' '); } for ($i = 156, $j = 0; $i < 512; $i++, $j++) { $v_checksum += ord(substr($v_binary_data_last, $j, 1)); } $this->_writeBlock($v_binary_data_first, 148); $v_checksum = sprintf("%06s ", DecOct($v_checksum)); $v_binary_data = pack("a8", $v_checksum); $this->_writeBlock($v_binary_data, 8); $this->_writeBlock($v_binary_data_last, 356); return true; } public function _writeLongHeader($p_filename) { $v_size = sprintf("%11s ", DecOct(strlen($p_filename))); $v_typeflag = 'L'; $v_linkname = ''; $v_magic = ''; $v_version = ''; $v_uname = ''; $v_gname = ''; $v_devmajor = ''; $v_devminor = ''; $v_prefix = ''; $v_binary_data_first = pack( "a100a8a8a8a12a12", '././@LongLink', 0, 0, 0, $v_size, 0 ); $v_binary_data_last = pack( "a1a100a6a2a32a32a8a8a155a12", $v_typeflag, $v_linkname, $v_magic, $v_version, $v_uname, $v_gname, $v_devmajor, $v_devminor, $v_prefix, '' ); $v_checksum = 0; for ($i = 0; $i < 148; $i++) { $v_checksum += ord(substr($v_binary_data_first, $i, 1)); } for ($i = 148; $i < 156; $i++) { $v_checksum += ord(' '); } for ($i = 156, $j = 0; $i < 512; $i++, $j++) { $v_checksum += ord(substr($v_binary_data_last, $j, 1)); } $this->_writeBlock($v_binary_data_first, 148); $v_checksum = sprintf("%06s ", DecOct($v_checksum)); $v_binary_data = pack("a8", $v_checksum); $this->_writeBlock($v_binary_data, 8); $this->_writeBlock($v_binary_data_last, 356); $i = 0; while (($v_buffer = substr($p_filename, (($i++) * 512), 512)) != '') { $v_binary_data = pack("a512", "$v_buffer"); $this->_writeBlock($v_binary_data); } return true; } public function _readHeader($v_binary_data, &$v_header) { if (strlen($v_binary_data) == 0) { $v_header['filename'] = ''; return true; } if (strlen($v_binary_data) != 512) { $v_header['filename'] = ''; $this->_error('Invalid block size : ' . strlen($v_binary_data)); return false; } if (!is_array($v_header)) { $v_header = array(); } $v_checksum = 0; for ($i = 0; $i < 148; $i++) { $v_checksum += ord(substr($v_binary_data, $i, 1)); } for ($i = 148; $i < 156; $i++) { $v_checksum += ord(' '); } for ($i = 156; $i < 512; $i++) { $v_checksum += ord(substr($v_binary_data, $i, 1)); } if (version_compare(PHP_VERSION, "5.5.0-dev") < 0) { $fmt = "a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/" . "a8checksum/a1typeflag/a100link/a6magic/a2version/" . "a32uname/a32gname/a8devmajor/a8devminor/a131prefix"; } else { $fmt = "Z100filename/Z8mode/Z8uid/Z8gid/Z12size/Z12mtime/" . "Z8checksum/Z1typeflag/Z100link/Z6magic/Z2version/" . "Z32uname/Z32gname/Z8devmajor/Z8devminor/Z131prefix"; } $v_data = unpack($fmt, $v_binary_data); if (strlen($v_data["prefix"]) > 0) { $v_data["filename"] = "$v_data[prefix]/$v_data[filename]"; } $v_header['checksum'] = OctDec(trim($v_data['checksum'])); if ($v_header['checksum'] != $v_checksum) { $v_header['filename'] = ''; if (($v_checksum == 256) && ($v_header['checksum'] == 0)) { return true; } $this->_error( 'Invalid checksum for file "' . $v_data['filename'] . '" : ' . $v_checksum . ' calculated, ' . $v_header['checksum'] . ' expected' ); return false; } $v_header['filename'] = rtrim($v_data['filename'], "\0"); if ($this->_maliciousFilename($v_header['filename'])) { $this->_error( 'Malicious .tar detected, file "' . $v_header['filename'] . '" will not install in desired directory tree' ); return false; } $v_header['mode'] = OctDec(trim($v_data['mode'])); $v_header['uid'] = OctDec(trim($v_data['uid'])); $v_header['gid'] = OctDec(trim($v_data['gid'])); $v_header['size'] = OctDec(trim($v_data['size'])); $v_header['mtime'] = OctDec(trim($v_data['mtime'])); if (($v_header['typeflag'] = $v_data['typeflag']) == "5") { $v_header['size'] = 0; } $v_header['link'] = trim($v_data['link']); return true; } private function _maliciousFilename($file) { if (strpos($file, '/../') !== false) { return true; } if (strpos($file, '../') === 0) { return true; } return false; } public function _readLongHeader(&$v_header) { $v_filename = ''; $v_filesize = $v_header['size']; $n = floor($v_header['size'] / 512); for ($i = 0; $i < $n; $i++) { $v_content = $this->_readBlock(); $v_filename .= $v_content; } if (($v_header['size'] % 512) != 0) { $v_content = $this->_readBlock(); $v_filename .= $v_content; } $v_binary_data = $this->_readBlock(); if (!$this->_readHeader($v_binary_data, $v_header)) { return false; } $v_filename = rtrim(substr($v_filename, 0, $v_filesize), "\0"); $v_header['filename'] = $v_filename; if ($this->_maliciousFilename($v_filename)) { $this->_error( 'Malicious .tar detected, file "' . $v_filename . '" will not install in desired directory tree' ); return false; } return true; } private function _extractInString($p_filename) { $v_result_str = ""; while (strlen($v_binary_data = $this->_readBlock()) != 0) { if (!$this->_readHeader($v_binary_data, $v_header)) { return null; } if ($v_header['filename'] == '') { continue; } if ($v_header['typeflag'] == 'L') { if (!$this->_readLongHeader($v_header)) { return null; } } if ($v_header['filename'] == $p_filename) { if ($v_header['typeflag'] == "5") { $this->_error( 'Unable to extract in string a directory ' . 'entry {' . $v_header['filename'] . '}' ); return null; } else { $n = floor($v_header['size'] / 512); for ($i = 0; $i < $n; $i++) { $v_result_str .= $this->_readBlock(); } if (($v_header['size'] % 512) != 0) { $v_content = $this->_readBlock(); $v_result_str .= substr( $v_content, 0, ($v_header['size'] % 512) ); } return $v_result_str; } } else { $this->_jumpBlock(ceil(($v_header['size'] / 512))); } } return null; } public function _extractList( $p_path, &$p_list_detail, $p_mode, $p_file_list, $p_remove_path, $p_preserve = false ) { $v_result = true; $v_nb = 0; $v_extract_all = true; $v_listing = false; $p_path = $this->_translateWinPath($p_path, false); if ($p_path == '' || (substr($p_path, 0, 1) != '/' && substr($p_path, 0, 3) != "../" && !strpos($p_path, ':')) ) { $p_path = "./" . $p_path; } $p_remove_path = $this->_translateWinPath($p_remove_path); if (($p_remove_path != '') && (substr($p_remove_path, -1) != '/')) { $p_remove_path .= '/'; } $p_remove_path_size = strlen($p_remove_path); switch ($p_mode) { case "complete" : $v_extract_all = true; $v_listing = false; break; case "partial" : $v_extract_all = false; $v_listing = false; break; case "list" : $v_extract_all = false; $v_listing = true; break; default : $this->_error('Invalid extract mode (' . $p_mode . ')'); return false; } clearstatcache(); while (strlen($v_binary_data = $this->_readBlock()) != 0) { $v_extract_file = false; $v_extraction_stopped = 0; if (!$this->_readHeader($v_binary_data, $v_header)) { return false; } if ($v_header['filename'] == '') { continue; } if ($v_header['typeflag'] == 'L') { if (!$this->_readLongHeader($v_header)) { return false; } } if ($v_header['typeflag'] == 'x' || $v_header['typeflag'] == 'g') { $this->_jumpBlock(ceil(($v_header['size'] / 512))); continue; } if ((!$v_extract_all) && (is_array($p_file_list))) { $v_extract_file = false; for ($i = 0; $i < sizeof($p_file_list); $i++) { if (substr($p_file_list[$i], -1) == '/') { if ((strlen($v_header['filename']) > strlen($p_file_list[$i])) && (substr($v_header['filename'], 0, strlen($p_file_list[$i])) == $p_file_list[$i]) ) { $v_extract_file = true; break; } } elseif ($p_file_list[$i] == $v_header['filename']) { $v_extract_file = true; break; } } } else { $v_extract_file = true; } if (($v_extract_file) && (!$v_listing)) { if (($p_remove_path != '') && (substr($v_header['filename'] . '/', 0, $p_remove_path_size) == $p_remove_path) ) { $v_header['filename'] = substr( $v_header['filename'], $p_remove_path_size ); if ($v_header['filename'] == '') { continue; } } if (($p_path != './') && ($p_path != '/')) { while (substr($p_path, -1) == '/') { $p_path = substr($p_path, 0, strlen($p_path) - 1); } if (substr($v_header['filename'], 0, 1) == '/') { $v_header['filename'] = $p_path . $v_header['filename']; } else { $v_header['filename'] = $p_path . '/' . $v_header['filename']; } } if (file_exists($v_header['filename'])) { if ((@is_dir($v_header['filename'])) && ($v_header['typeflag'] == '') ) { $this->_error( 'File ' . $v_header['filename'] . ' already exists as a directory' ); return false; } if (($this->_isArchive($v_header['filename'])) && ($v_header['typeflag'] == "5") ) { $this->_error( 'Directory ' . $v_header['filename'] . ' already exists as a file' ); return false; } if (!is_writeable($v_header['filename'])) { $this->_error( 'File ' . $v_header['filename'] . ' already exists and is write protected' ); return false; } if (filemtime($v_header['filename']) > $v_header['mtime']) { } } elseif (($v_result = $this->_dirCheck( ($v_header['typeflag'] == "5" ? $v_header['filename'] : dirname($v_header['filename'])) )) != 1 ) { $this->_error('Unable to create path for ' . $v_header['filename']); return false; } if ($v_extract_file) { if ($v_header['typeflag'] == "5") { if (!@file_exists($v_header['filename'])) { if (!@mkdir($v_header['filename'], 0777)) { $this->_error( 'Unable to create directory {' . $v_header['filename'] . '}' ); return false; } } } elseif ($v_header['typeflag'] == "2") { if (@file_exists($v_header['filename'])) { @unlink($v_header['filename']); } if (!@symlink($v_header['link'], $v_header['filename'])) { $this->_error( 'Unable to extract symbolic link {' . $v_header['filename'] . '}' ); return false; } } else { if (($v_dest_file = @fopen($v_header['filename'], "wb")) == 0) { $this->_error( 'Error while opening {' . $v_header['filename'] . '} in write binary mode' ); return false; } else { $n = floor($v_header['size'] / 512); for ($i = 0; $i < $n; $i++) { $v_content = $this->_readBlock(); fwrite($v_dest_file, $v_content, 512); } if (($v_header['size'] % 512) != 0) { $v_content = $this->_readBlock(); fwrite($v_dest_file, $v_content, ($v_header['size'] % 512)); } @fclose($v_dest_file); if ($p_preserve) { @chown($v_header['filename'], $v_header['uid']); @chgrp($v_header['filename'], $v_header['gid']); } @touch($v_header['filename'], $v_header['mtime']); if ($v_header['mode'] & 0111) { $mode = fileperms($v_header['filename']) | (~umask() & 0111); @chmod($v_header['filename'], $mode); } } clearstatcache(); if (!is_file($v_header['filename'])) { $this->_error( 'Extracted file ' . $v_header['filename'] . 'does not exist. Archive may be corrupted.' ); return false; } $filesize = filesize($v_header['filename']); if ($filesize != $v_header['size']) { $this->_error( 'Extracted file ' . $v_header['filename'] . ' does not have the correct file size \'' . $filesize . '\' (' . $v_header['size'] . ' expected). Archive may be corrupted.' ); return false; } } } else { $this->_jumpBlock(ceil(($v_header['size'] / 512))); } } else { $this->_jumpBlock(ceil(($v_header['size'] / 512))); } if ($v_listing || $v_extract_file || $v_extraction_stopped) { if (($v_file_dir = dirname($v_header['filename'])) == $v_header['filename'] ) { $v_file_dir = ''; } if ((substr($v_header['filename'], 0, 1) == '/') && ($v_file_dir == '')) { $v_file_dir = '/'; } $p_list_detail[$v_nb++] = $v_header; if (is_array($p_file_list) && (count($p_list_detail) == count($p_file_list))) { return true; } } } return true; } public function _openAppend() { if (filesize($this->_tarname) == 0) { return $this->_openWrite(); } if ($this->_compress) { $this->_close(); if (!@rename($this->_tarname, $this->_tarname . ".tmp")) { $this->_error( 'Error while renaming \'' . $this->_tarname . '\' to temporary file \'' . $this->_tarname . '.tmp\'' ); return false; } if ($this->_compress_type == 'gz') { $v_temp_tar = @gzopen($this->_tarname . ".tmp", "rb"); } elseif ($this->_compress_type == 'bz2') { $v_temp_tar = @bzopen($this->_tarname . ".tmp", "r"); } elseif ($this->_compress_type == 'lzma2') { $v_temp_tar = @xzopen($this->_tarname . ".tmp", "r"); } if ($v_temp_tar == 0) { $this->_error( 'Unable to open file \'' . $this->_tarname . '.tmp\' in binary read mode' ); @rename($this->_tarname . ".tmp", $this->_tarname); return false; } if (!$this->_openWrite()) { @rename($this->_tarname . ".tmp", $this->_tarname); return false; } if ($this->_compress_type == 'gz') { $end_blocks = 0; while (!@gzeof($v_temp_tar)) { $v_buffer = @gzread($v_temp_tar, 512); if ($v_buffer == ARCHIVE_TAR_END_BLOCK || strlen($v_buffer) == 0) { $end_blocks++; continue; } elseif ($end_blocks > 0) { for ($i = 0; $i < $end_blocks; $i++) { $this->_writeBlock(ARCHIVE_TAR_END_BLOCK); } $end_blocks = 0; } $v_binary_data = pack("a512", $v_buffer); $this->_writeBlock($v_binary_data); } @gzclose($v_temp_tar); } elseif ($this->_compress_type == 'bz2') { $end_blocks = 0; while (strlen($v_buffer = @bzread($v_temp_tar, 512)) > 0) { if ($v_buffer == ARCHIVE_TAR_END_BLOCK || strlen($v_buffer) == 0) { $end_blocks++; continue; } elseif ($end_blocks > 0) { for ($i = 0; $i < $end_blocks; $i++) { $this->_writeBlock(ARCHIVE_TAR_END_BLOCK); } $end_blocks = 0; } $v_binary_data = pack("a512", $v_buffer); $this->_writeBlock($v_binary_data); } @bzclose($v_temp_tar); } elseif ($this->_compress_type == 'lzma2') { $end_blocks = 0; while (strlen($v_buffer = @xzread($v_temp_tar, 512)) > 0) { if ($v_buffer == ARCHIVE_TAR_END_BLOCK || strlen($v_buffer) == 0) { $end_blocks++; continue; } elseif ($end_blocks > 0) { for ($i = 0; $i < $end_blocks; $i++) { $this->_writeBlock(ARCHIVE_TAR_END_BLOCK); } $end_blocks = 0; } $v_binary_data = pack("a512", $v_buffer); $this->_writeBlock($v_binary_data); } @xzclose($v_temp_tar); } if (!@unlink($this->_tarname . ".tmp")) { $this->_error( 'Error while deleting temporary file \'' . $this->_tarname . '.tmp\'' ); } } else { if (!$this->_openReadWrite()) { return false; } clearstatcache(); $v_size = filesize($this->_tarname); fseek($this->_file, $v_size - 1024); if (fread($this->_file, 512) == ARCHIVE_TAR_END_BLOCK) { fseek($this->_file, $v_size - 1024); } elseif (fread($this->_file, 512) == ARCHIVE_TAR_END_BLOCK) { fseek($this->_file, $v_size - 512); } } return true; } public function _append($p_filelist, $p_add_dir = '', $p_remove_dir = '') { if (!$this->_openAppend()) { return false; } if ($this->_addList($p_filelist, $p_add_dir, $p_remove_dir)) { $this->_writeFooter(); } $this->_close(); return true; } public function _dirCheck($p_dir) { clearstatcache(); if ((@is_dir($p_dir)) || ($p_dir == '')) { return true; } $p_parent_dir = dirname($p_dir); if (($p_parent_dir != $p_dir) && ($p_parent_dir != '') && (!$this->_dirCheck($p_parent_dir)) ) { return false; } if (!@mkdir($p_dir, 0777)) { $this->_error("Unable to create directory '$p_dir'"); return false; } return true; } private function _pathReduction($p_dir) { $v_result = ''; if ($p_dir != '') { $v_list = explode('/', $p_dir); for ($i = sizeof($v_list) - 1; $i >= 0; $i--) { if ($v_list[$i] == ".") { } else { if ($v_list[$i] == "..") { $i--; } else { if (($v_list[$i] == '') && ($i != (sizeof($v_list) - 1)) && ($i != 0) ) { } else { $v_result = $v_list[$i] . ($i != (sizeof($v_list) - 1) ? '/' . $v_result : ''); } } } } } if (defined('OS_WINDOWS') && OS_WINDOWS) { $v_result = strtr($v_result, '\\', '/'); } return $v_result; } public function _translateWinPath($p_path, $p_remove_disk_letter = true) { if (defined('OS_WINDOWS') && OS_WINDOWS) { if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false) ) { $p_path = substr($p_path, $v_position + 1); } if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0, 1) == '\\')) { $p_path = strtr($p_path, '\\', '/'); } } return $p_path; } }
\ No newline at end of file
diff --git a/fileadmin/unpack.php b/fileadmin/unpack.php
new file mode 100644
index 00000000..48714156
--- /dev/null
+++ b/fileadmin/unpack.php
@@ -0,0 +1,161 @@
+\n";
+echo "返回目录 解压结果\n";
+echo "\n";
+echo "\n";
+switch ($type) {
+ case "gz" :
+ if (!function_exists("gzopen")) {
+ echo "系统没有支持核心函数!";
+ } else {
+ $fp = preg_replace("/(.*?)\.gz$/si", "\\1", $unpackdir . "/" . basename($path));
+ if (file_exists($fp)) {
+ echo "目标文件已经存在了哦!";
+ } elseif (!($gz = gzopen($path, "r"))) {
+ echo "系统无法打开压缩文件!";
+ } else {
+ if (!($fp = fopen($fp, "wb"))) {
+ echo "系统无法保存解压文件!";
+ } else {
+ while (!feof($gz)) {
+ fwrite($fp, gzread($gz, 4096));
+ }
+ gzclose($gz);
+ fclose($fp);
+ echo "压缩文件已经解压完成!";
+ }
+ }
+ }
+ break;
+ case "bz2" :
+ if (!function_exists("bzopen")) {
+ echo "系统没有支持核心函数!";
+ } else {
+ $fp = preg_replace("/(.*?)\.bz2$/si", "\\1", $unpackdir . "/" . basename($path));
+ if (file_exists($fp)) {
+ echo "目标文件已经存在了哦!";
+ } elseif (!($bz2 = bzopen($path, "r"))) {
+ echo "系统无法打开压缩文件!";
+ } else {
+ if (!($fp = fopen($fp, "wb"))) {
+ echo "系统无法保存解压文件!";
+ } else {
+ while (!feof($bz2)) {
+ fwrite($fp, bzread($bz2, 4096));
+ }
+ bzclose($bz2);
+ fclose($fp);
+ echo "压缩文件已经解压完成!";
+ }
+ }
+ }
+ break;
+ case "zip" :
+ if (!file_exists("pclzip.php")) {
+ echo "暂时无法进行解压操作!";
+ } else {
+ require "pclzip.php";
+ $pk = new pclzip($path);
+ if (($zip = $pk->extract(PCLZIP_OPT_PATH, $unpackdir)) == false) {
+ echo "无法成功解压您的文件!";
+ } else {
+ echo "成功解压出 " . count($zip) . " 个档案!";
+ }
+ }
+ break;
+ case "tar" :
+ if (!file_exists("tarcls.php")) {
+ echo "暂时无法进行解压操作!";
+ } else {
+ require "tarcls.php";
+ $pk = new Archive_Tar($path);
+ if ($pk->extract($unpackdir) == false) {
+ echo "无法成功解压您的文件!";
+ } else {
+ echo "成功的对文件进行解压!";
+ }
+ }
+ break;
+ case "7za" :
+ $bin = "./p7zip.bin";
+ if (is_file($bin)) {
+ if (function_exists("chmod")) {
+ chmod($bin, 0700);
+ if (!is_executable($bin)) {
+ $tmp = sys_get_temp_dir() . '/p7zip.bin';
+ if (copy($bin, $tmp)) {
+ chmod($tmp, 0700);
+ !is_executable($tmp) ? $bin = false : $bin = $tmp;
+ } else {
+ $bin = false;
+ }
+ }
+ }
+ }
+ if (___superexec($bin) == "") {
+ if (___superexec('7z') != "") {
+ $bin = "7z";
+ } elseif (___superexec('7za') != "") {
+ $bin = "7za";
+ }
+ }
+ if (___superexec($bin) == "") {
+ echo "程序无法正常完成工作!";
+ } else {
+ $a = addslashes($path);
+ $b = addslashes($unpackdir);
+ $c = isset($_GET['password']) ? addslashes(trim($_GET['password'])) : null;
+ echo nl2br(___codepre(___convert(___superexec("$bin x '$a' '-o$b' '-p$c' -y 2>&1"), "UTF-8")));
+ }
+ break;
+ case "rar" :
+ $bin = "./unrar.bin";
+ if (is_file($bin)) {
+ if (function_exists("chmod")) {
+ chmod($bin, 0700);
+ if (!is_executable($bin)) {
+ $tmp = sys_get_temp_dir() . '/unrar.bin';
+ if (copy($bin, $tmp)) {
+ chmod($tmp, 0700);
+ !is_executable($tmp) ? $bin = false : $bin = $tmp;
+ } else {
+ $bin = false;
+ }
+ }
+ }
+ }
+ if (___superexec($bin) == "") {
+ if (___superexec('rar') != "") {
+ $bin = "rar";
+ } elseif (___superexec('unrar') != "") {
+ $bin = "unrar";
+ }
+ }
+ if (___superexec($bin) == "") {
+ echo "程序无法正常完成工作!";
+ } else {
+ $a = addslashes($path);
+ $b = addslashes($unpackdir);
+ $c = isset($_GET['password']) ? addslashes(trim($_GET['password'])) : null;
+ if ($c == null) {
+ echo nl2br(___codepre(___convert(___superexec("$bin x -y '$a' '$b' 2>&1"), "UTF-8")));
+ } else {
+ echo nl2br(___codepre(___convert(___superexec("$bin x -y '-p$c' '$a' '$b' 2>&1"), "UTF-8")));
+ }
+ }
+ break;
+ default :
+ echo "暂时不支持的压缩类型!";
+}
+echo "
\n";
+xhtml_footer();
+?>
diff --git a/fileadmin/unzip.php b/fileadmin/unzip.php
new file mode 100644
index 00000000..3c1b10cf
--- /dev/null
+++ b/fileadmin/unzip.php
@@ -0,0 +1,75 @@
+\n";
+ echo "返回目录 错误提示\n";
+ echo "\n";
+ echo "\n";
+ echo "此文件暂时不能被系统操作!";
+ echo "
\n";
+ xhtml_footer();
+ exit;
+}
+xhtml_head("爱特ZIP工具");
+if (isset($_POST['z']) && is_array($_POST['z']) && isset($_POST['undir']) && is_dir(trim($_POST['undir']))) {
+ echo "\n";
+ echo "
返回目录 解压结果\n";
+ echo "
\n";
+ $pk = new pclzip($path);
+ $dir = trim($_POST['undir']);
+ $arr = array_map('urldecode', $_POST['z']);
+ if (($zip = $pk->extract(PCLZIP_OPT_PATH, $dir, PCLZIP_OPT_BY_NAME, $arr)) == false) {
+ echo "\n";
+ echo "无法成功解压您的文件!";
+ echo "\n
\n";
+ } else {
+ echo "\n";
+ echo "本次共操作 " . count($zip) . " 个档案!";
+ echo "\n
\n";
+ foreach ($zip as $zf) {
+ echo "\n";
+ if ($zf['folder']) {
+ echo "[目录]";
+ } else {
+ echo "[文件]";
+ }
+ echo ___convert($zf['filename'], "UTF-8") . "(" . $zf['status'] . ")\n \n";
+ echo "
\n";
+ }
+ }
+} else {
+ echo "\n";
+ echo "
返回目录 文件列表\n";
+ echo "
\n";
+ echo "\n";
+ echo "\n";
+ $unzipdir = dirname($path);
+ isset($_GET['unzipdir']) && is_dir($_GET['unzipdir']) && $unzipdir = trim($_GET['unzipdir']);
+ echo "解压
到此 路径:\n";
+ echo "
\n";
+ echo "
\n";
+ echo "(
全选 |
消选 )\n";
+ echo "
\n";
+ $select = isset($_GET['select']) ? "checked " : null;
+ foreach ($ziplist as $zfile) {
+ echo "\n";
+ echo " \n";
+ if ($zfile['folder']) {
+ echo "[目录]" . ___codepre(___convert($zfile['stored_filename'], "UTF-8"));
+ } else {
+ echo "[文件]" . ___codepre(___convert($zfile['stored_filename'], "UTF-8"));
+ echo "(" . ___filesize($zfile['size']) . "->" . ___filesize($zfile['compressed_size']) . ")";
+ }
+ echo "\n
\n";
+ }
+ echo " \n";
+}
+xhtml_footer();
+?>
diff --git a/fileadmin/upload.php b/fileadmin/upload.php
new file mode 100644
index 00000000..ea57cd64
--- /dev/null
+++ b/fileadmin/upload.php
@@ -0,0 +1,139 @@
+\n";
+echo "返回目录 \n";
+if (isset($_GET['url'])) {
+ echo "本地上传 \n";
+} else {
+ echo "远程上传 \n";
+}
+echo "\n";
+echo "\n";
+echo "
\n";
+echo " \n";
+if (isset($_GET['url'])) echo " \n";
+echo "数量-> \n";
+echo " \n";
+echo " \n";
+echo "\n";
+if (isset($_GET['url'])) {
+ if (isset($_POST['fupload'])) if (is_array($_POST['fupload'])) if (count($_POST['fupload']) > 0) {
+ $o = 0;
+ $i = 0;
+ echo "上传文件信息报告
\n";
+ while ($i < count($_POST['fupload'])) {
+ if (!preg_match("/^[a-z0-9]+\:\/\/.+/si", $_POST['fupload'][$i])) {
+ $i++;
+ continue;
+ }
+ preg_match("/[^\/\?&\s\:\\\]+$/i", $_POST['fupload'][$i], $fname);
+ $fname = $fname[0] != "" ? $fname[0] : time() . ".file";
+ if (!($fp = fopen(trim($_POST['fupload'][$i]), "rb"))) {
+ echo "\n";
+ echo "{$fname}(Error !)\n";
+ echo "
\n";
+ } elseif (!($fp2 = fopen($fpath = "$getcwd/$fname", "wb"))) {
+ echo "\n";
+ echo "{$fname}(Error !)\n";
+ echo "
\n";
+ } else {
+ while (!feof($fp)) {
+ fwrite($fp2, fread($fp, 4096));
+ }
+ fclose($fp);
+ fclose($fp2);
+ if (filesize($fpath) > 0) {
+ echo "\n";
+ echo "{$fname}(Yes !)\n";
+ echo "
\n";
+ } else {
+ unlink($fpath);
+ echo "\n";
+ echo "{$fname}(Error !)\n";
+ echo "
\n";
+ }
+ }
+ $o++;
+ $i++;
+ }
+ if ($o < 1) echo "郁闷,没有任何文件被上传!\n";
+ }
+ echo "输入您的上传地址
\n";
+ echo "\n";
+ if (!isset($_GET['uploadnum'])) {
+ echo "\n";
+ echo "地址[+] \n";
+ echo "
\n";
+ } else {
+ $i = 0;
+ $uploadnum = (int)trim($_GET['uploadnum']);
+ if ($uploadnum < 1) $uploadnum = 1;
+ while ($i < $uploadnum) {
+ echo "\n";
+ echo "地址[" . ($i + 1) . "] \n";
+ echo "
\n";
+ $i++;
+ }
+ }
+ echo "\n";
+ echo " (有效 地址)\n";
+ echo "
\n";
+ echo " \n";
+} else {
+ if (isset($_FILES['fupload'])) if (count($_FILES['fupload']) > 0) {
+ $o = 0;
+ $i = 0;
+ echo "上传文件信息报告
\n";
+ while ($i < count($_FILES['fupload']['size'])) {
+ if ($_FILES['fupload']['size'][$i] < 1) {
+ $i++;
+ continue;
+ }
+ if (!move_uploaded_file($_FILES['fupload']['tmp_name'][$i], $getcwd . "/" . $_FILES['fupload']['name'][$i])) {
+ echo "\n";
+ echo "{$_FILES['fupload']['name'][$i]}(Error !)\n";
+ echo "
\n";
+ } else {
+ echo "\n";
+ echo "{$_FILES['fupload']['name'][$i]}(" . ___filesize($_FILES['fupload']['size'][$i]) . ")\n";
+ echo "
\n";
+ }
+ $o++;
+ $i++;
+ }
+ if ($o < 1) echo "郁闷,没有任何文件被上传!\n";
+ }
+ echo "选择您的上传文件
\n";
+ echo "\n";
+ if (!isset($_GET['uploadnum'])) {
+ echo "\n";
+ echo "文件[+] \n";
+ echo "
\n";
+ } else {
+ $i = 0;
+ $uploadnum = (int)trim($_GET['uploadnum']);
+ if ($uploadnum < 1) $uploadnum = 1;
+ while ($i < $uploadnum) {
+ echo "\n";
+ echo "文件[" . ($i + 1) . "] \n";
+ echo "
\n";
+ $i++;
+ }
+ }
+ echo "\n";
+ echo " (有效 文件)\n";
+ echo "
\n";
+ echo " \n";
+}
+xhtml_footer();
+?>
diff --git a/fileadmin/view.php b/fileadmin/view.php
new file mode 100644
index 00000000..47a17ed6
--- /dev/null
+++ b/fileadmin/view.php
@@ -0,0 +1,86 @@
+\n";
+ echo "返回目录 错误提示\n";
+ echo "\n";
+ echo "\n";
+ echo "此文件您没有读取权限!";
+ echo "
\n";
+ xhtml_footer();
+} else {
+ xhtml_head("查看文件");
+ echo "\n";
+ echo "
返回目录 选择编码\n";
+ echo "
\n";
+ echo "";
+ echo "
\n";
+ echo "\n";
+ if (!function_exists("mb_convert_encoding")) {
+ echo "缺少模块 \n";
+ } else {
+ $sencode = mb_list_encodings();
+ usort($sencode, "___sortcmp");
+ foreach ($sencode as $encode) {
+ if ($encode == "pass") {
+ continue;
+ }
+ if (function_exists("mb_encoding_aliases")) {
+ $alias = mb_encoding_aliases($encode);
+ echo "\n\n";
+ echo "$encode \n";
+ if (is_array($alias)) if (count($alias) >= 1) {
+ usort($alias, "___sortcmp");
+ foreach ($alias as $encodealias) {
+ if ($encodealias == $encode) {
+ continue;
+ }
+ echo "$encodealias \n";
+ }
+ }
+ echo " \n";
+ } else {
+ echo "$encode \n";
+ }
+ }
+ }
+ echo " \n";
+ echo " ";
+ echo " \n";
+ echo " \n";
+ echo "\n";
+ echo "爱特文件内容浏览
\n";
+ if (filesize($path) > (2 * 1024 * 1024)) {
+ echo "\n";
+ echo "文件过大,请下载后查看!\n";
+ echo "
\n";
+ } else {
+ echo "\n";
+ if (!($data = file_get_contents($path))) {
+ echo "读取文件时发生了错误!\n";
+ } else {
+ echo "
";
+ if (!isset($_GET['charset'])) {
+ echo nl2br(___codepre(___convert(trim($data), "UTF-8")));
+ } elseif (($charset = trim($_GET['charset'])) == "") {
+ echo nl2br(___codepre(___convert(trim($data), "UTF-8")));
+ } else {
+ echo nl2br(___codepre(___convert(trim($data), "UTF-8", $charset)));
+ }
+ echo "\n";
+ }
+ echo " ";
+ }
+ xhtml_footer();
+}
+?>
diff --git a/fileadmin/xhtml.php b/fileadmin/xhtml.php
new file mode 100644
index 00000000..c988b2a8
--- /dev/null
+++ b/fileadmin/xhtml.php
@@ -0,0 +1,33 @@
+
+
+
+ {$title} - 〔{$name}〕
+
+
+
+
+
+XHTML;
+}
+
+function xhtml_footer()
+{
+ echo <<