-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindpost.php
More file actions
81 lines (68 loc) · 2.28 KB
/
indpost.php
File metadata and controls
81 lines (68 loc) · 2.28 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
<?php
// (c) 2014 Slamet Badwi
include('config.php');
include('common.php');
$dists = $_repo_list;
$mirrors = $_mirror_list;
$packages = '';
$dist = 0;
$mirror = 0;
if (isset($_POST)) {
$packages = isset($_POST['packages']) ? trim($_POST['packages']) : '';
$dist = isset($_POST['dist']) ? intval(trim($_POST['dist'])) : 0;
$mirror = isset($_POST['mirror']) ? intval(trim($_POST['mirror'])) : 0;
if (($packages != '') && (isset($_repo_list[$dist]))) {
// Get package dependencies and their URLs
$res = apt_install($_repo_list[$dist][0], $packages);
$res = parse_install($res);
$tbInstalled = &$res['packages'];
//$install = &$res['install'];
if (isset($_mirror_list[$mirror])) {
while (list($key, $val) = each($tbInstalled)) {
$tbInstalled[$key][0] = convert_url($tbInstalled[$key][0], $_mirror_list[$mirror][0]);
}
}
}
while(list($key, $val) = each($dists)) {
if($key == $dist)
echo "Results for profile: <strong>".$val[1]."</strong><br/><br/>";
}
echo '<ol>';
foreach($tbInstalled as $package) {
echo '<li><a href="'.$package[0].'">'.$package[1].'</a></li>';
$ukuran[] = $package[2];
}
echo '</ol>';
function humanFileSize($size,$unit="") {
if( (!$unit && $size >= 1<<30) || $unit == "GB")
return number_format($size/(1<<30),2)." GB";
if( (!$unit && $size >= 1<<20) || $unit == "MB")
return number_format($size/(1<<20),2)." MB";
if( (!$unit && $size >= 1<<10) || $unit == "KB")
return number_format($size/(1<<10),2)." KB";
return number_format($size)." bytes";
}
if($res != NULL){
if($tbInstalled != NULL){
$ukuran = array_sum($ukuran);
if($ukuran < 1024000) {
echo "<strong>Total size:</strong> $ukuran bytes <strong>(".humanFileSize($ukuran,"KB").")</strong>";
} else {
echo "<strong>Total size:</strong> $ukuran bytes <strong>(".humanFileSize($ukuran,"MB").")</strong>";
}
}
else
{
echo $packages." had been installed";
}
}
else
{
echo "Cannot proceed your request searching for package(s) <span class=\"text-info\"><strong>".$packages."</strong></span>, it's likely you have misspelled.";
}
}
else
{
return false;
}
?>