forked from Th3-822/rapidleech
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpack.php
More file actions
111 lines (110 loc) · 3.5 KB
/
Copy pathpack.php
File metadata and controls
111 lines (110 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
function rl_pack() {
global $list, $options, $PHP_SELF;
?>
<form method="post" action="<?php echo $PHP_SELF; ?>"><input type="hidden" name="act" value="pack_go" />
<?php
echo count ( $_GET ["files"] ) . " file" . (count ( $_GET ["files"] ) > 1 ? "s" : "") . ":<br />";
for($i = 0; $i < count ( $_GET ["files"] ); $i ++) {
$file = $list [$_GET ["files"] [$i]];
?>
<input type="hidden" name="files[]" value="<?php echo $_GET ["files"] [$i]; ?>" />
<b><?php echo basename ( $file ["name"] ); ?></b><?php echo $i == count ( $_GET ["files"] ) - 1 ? "." : ", "; }?><br />
<br />
<table align="center">
<tr>
<td><?php echo lang(195); ?>: <input type="text" name="arc_name" size="30" value="" /> <b>.</b>
<select name="arc_ext">
<option value="tar" selected="selected">tar</option>
<?php
if (!$options['disable_archive_compression']) {
?>
<option value="tar.gz">tar.gz</option>
<option value="tar.bz">tar.bz</option>
<?php
}
?>
</select>
</td>
<td><input type="submit" value="Pack" /></td>
</tr>
<?php
if ($options['download_dir_is_changeable']) {
?>
<tr>
<td><?php echo lang(40); ?>: <input type="text" name="saveTo" size="30"
value="<?php echo addslashes ( $options['download_dir'] ); ?>" /></td>
</tr>
<?php
}
?>
</table>
</form>
<?php
}
function pack_go() {
global $list, $options;
$arc_name = basename($_POST["arc_name"].'.'.$_POST["arc_ext"]);
$saveTo = ($options['download_dir_is_changeable'] ? stripslashes ( $_POST ["saveTo"] [$i] ) : realpath ( $options['download_dir'] )) . '/';
$v_list = array();
if (!$_POST["arc_name"] || !$_POST["arc_ext"]) {
echo lang(196)."<br /><br />";
}
elseif (file_exists ( $saveTo . $arc_name )) {
printf(lang(179),$arc_name);
echo "<br /><br />";
}
else {
for($i = 0; $i < count ( $_POST ["files"] ); $i ++) {
$file = $list [$_POST ["files"] [$i]];
if (file_exists ( $file ["name"] )) {
$v_list [] = $file ["name"];
} else {
printf(lang(145),$file['name']);
echo "<br /><br />";
}
}
if (count($v_list) < 1) {
echo lang(137)."<br /><br />";
}
else {
$arc_name = $saveTo.$arc_name;
require_once (CLASS_DIR . "tar.php");
$tar = new Archive_Tar ( $arc_name );
if ($tar->error != '') { echo $tar->error."<br /><br />"; }
else {
$remove_path = realpath($options['download_dir']).'/';
$tar->createModify($v_list, '', $remove_path);
if (! file_exists ( $arc_name )) {
echo lang(197)."<br /><br />";
}
else {
if (count ( $v_list = $tar->listContent () ) > 0) {
for($i = 0; $i < sizeof ( $v_list ); $i ++) {
printf(lang(198),$v_list[$i]['filename']);
echo " <br />";
}
printf(lang(199),$arc_name);
echo "<br />";
$stmp = strtolower ( $arc_name );
$arc_method = "Tar";
if (!$options['disable_archive_compression']) {
if (strrchr ( $stmp, "tar.gz" ) + 5 == strlen ( $stmp )) { $arc_method = "Tar.gz"; }
elseif (strrchr ( $stmp, "tar.bz2" ) + 6 == strlen ( $stmp )) { $arc_method = "Tar.bz2"; }
}
unset ( $stmp );
$time = explode ( " ", microtime () );
$time = str_replace ( "0.", $time [1], $time [0] );
$list [$time] = array ("name" => $arc_name, "size" => bytesToKbOrMbOrGb ( filesize ( $arc_name ) ), "date" => $time, "link" => "", "comment" => "archive " . $arc_method );
} else {
echo lang(200)."<br /><br />";
}
if (! updateListInFile ( $list )) {
echo lang(9).'<br /><br />';
}
}
}
}
}
}
?>