Skip to content
This repository was archived by the owner on Aug 19, 2021. It is now read-only.

Commit b4df84a

Browse files
authored
update v0.2
1 parent e8981b9 commit b4df84a

File tree

10 files changed

+505
-97
lines changed

10 files changed

+505
-97
lines changed

core/system/dir.php

Lines changed: 177 additions & 40 deletions
Large diffs are not rendered by default.

core/system/kernel/loader.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
77
https://github.com/michioxd/bakafiles
88
9-
File: loader.php (System Kernel :)))))
9+
File: loader.php
1010
*/
1111
require __DIR__ . '/sys.php';
1212
require __DIR__ . '/../../ui/header.php';
13-
1413
require __DIR__ . '/../../ui/footer.php';

core/system/kernel/sys.php

Lines changed: 95 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,36 @@
11
<?php
2+
/* bakafiles >~<
3+
by Michio Nakano (michio.xd)
4+
5+
License: GNU GENERAL PUBLIC LICENSE (GPL)
6+
7+
https://github.com/michioxd/bakafiles
8+
9+
File: sys.php
10+
*/
11+
ini_set('max_execution_time', 0);
12+
ini_set('post_max_size', '100000000');
13+
ini_set('upload_max_filesize', '100000000');
214
if (file_exists(__DIR__ . '/../../../bakafiles-this_is-your_config.php')) {
315

416
include(__DIR__ . '/../../../bakafiles-this_is-your_config.php');
517
} else {
6-
718
include __DIR__ . '/../../ui/error/no-config.php';
819
exit();
920
}
10-
define("VERSION", "v0.1");
21+
define("VERSION_BKF", "v0.2");
22+
define("VERSION", "0.2");
23+
include __DIR__ . '/update_core/server.php';
24+
$_get_update = file_get_contents(UPDATE_SERVER);
25+
if ($_get_update == null) {
26+
$__uversion = "2";
27+
} else {
28+
if (version_compare(VERSION, $_get_update) >= 0) {
29+
$__uversion = "0";
30+
} else {
31+
$__uversion = "1";
32+
}
33+
}
1134
function mime_mdicon($dir)
1235
{
1336
if (mime_content_type($dir) == "directory") {
@@ -28,10 +51,31 @@ function mime_mdicon($dir)
2851
echo "insert_drive_file";
2952
}
3053
}
31-
if (isset($_POST['dir_del']) == true) {
54+
function load_image_b64($path)
55+
{
56+
$type = pathinfo($path, PATHINFO_EXTENSION);
57+
$data = file_get_contents($path);
58+
return 'data:image/' . $type . ';base64,' . base64_encode($data);
59+
}
60+
function load_file_size($path)
61+
{
62+
if (mime_content_type($path) == "directory") {
63+
return "baka dir >~<";
64+
} else {
65+
$size = filesize($path);
66+
$units = array('Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB');
67+
$res = @round($size / pow(1024, ($i = floor(log($size, 1024)))), 2) . ' ' . $units[$i];
68+
if ($res == "NAN Bytes") {
69+
return "0 Bytes";
70+
} else {
71+
return $res;
72+
}
73+
}
74+
}
75+
if (isset($_POST['dir_del'], $_POST['del_last_dir']) == true) {
3276
if (file_exists(urldecode($_POST['dir_del']))) {
33-
rmdir(urldecode($_POST['dir_del']));
34-
echo '<script>alert("Xóa cmn thành cmn công :)))\ndel your dir complete\nフォルダを完全に削除します\n\n bakafiles");cload("core/system/dir.php");</script>';
77+
deleteDirectory(urldecode($_POST['dir_del']));
78+
echo '<script>alert("Xóa cmn thành cmn công :)))\ndel your dir complete\nフォルダを完全に削除します\n\n bakafiles");cload("core/system/dir.php?dir=' . $_POST['del_last_dir'] . '");</script>';
3579
} else {
3680
echo '<script>alert("Tệp không tồn tại :<\nFile not found :<\nファイルが見つかりません\n\n bakafiles")</script>';
3781
}
@@ -41,22 +85,53 @@ function mime_mdicon($dir)
4185
if (isset($_POST['dir_f_del']) == true) {
4286
if (file_exists(urldecode($_POST['dir_f_del']))) {
4387
unlink(urldecode($_POST['dir_f_del']));
44-
echo '<script>alert("Xóa tệp cmn thành cmn công :)))\ndel your file complete\nあなたのファイルを削除完了\n\n bakafiles");cload("core/system/dir.php");</script>';
88+
echo '<script>alert("Xóa tệp cmn thành cmn công :)))\ndel your file complete\nあなたのファイルを削除完了\n\n bakafiles");cload("core/system/dir.php?dir=' . $_POST['del_last_dir'] . '");</script>';
4589
} else {
4690
echo '<script>alert("Tệp không tồn tại :<\nFile not found :<\nファイルが見つかりません\n\n bakafiles")</script>';
4791
}
4892
exit();
4993
}
50-
if (isset($_POST['cre_new_f'], $_POST['cre_new_f_dir'])) {
94+
if (isset($_POST['cre_new_f'], $_POST['cre_new_f_dir'], $_POST['cre_new_f_last_dir'])) {
5195
if ($_POST['cre_new_f'] == null) {
5296
echo '<script>alert("Vui lòng nhập tên file :<\nPlease enter file name :<\nファイル名を入力してください\n\n bakafiles")</script>';
5397
} else {
5498
$uri = urldecode($_POST['cre_new_f_dir'] . "/" . $_POST['cre_new_f']);
5599
$loadfile = fopen($uri, "w") or die('<script>alert("Không thể tạo file :<\nCouldn\'t create new file :<\n新しいファイルを作成できませんでした\n\n bakafiles")</script>');
56100
fclose($loadfile);
57-
echo '<script>alert("Đã tạo file!\nCreated file!\n作成したファイル\n\n bakafiles");cload("core/system/dir.php?dir=");</script>';
101+
echo '<script>alert("Đã tạo file!\nCreated file!\n作成したファイル\n\n bakafiles");cload("core/system/dir.php?dir=' . $_POST['cre_new_f_last_dir'] . '");</script>';
58102
}
59103
}
104+
if (isset($_POST['cre_new_dir'], $_POST['cre_new_dir_dir'], $_POST['cre_new_dir_last_dir'])) {
105+
if ($_POST['cre_new_dir'] == null) {
106+
echo '<script>alert("Vui lòng nhập tên folder :<\nPlease enter folder name :<\nフォルダ名を入力してください\n\n bakafiles")</script>';
107+
} else {
108+
$uri = urldecode($_POST['cre_new_dir_dir'] . "/" . $_POST['cre_new_dir']);
109+
mkdir($uri, 0777) or die('<script>alert("Không thể tạo folder :<\nCouldn\'t create new folder :<\新しいフォルダを作成できませんでした\n\n bakafiles")</script>');
110+
echo '<script>alert("Đã tạo folder!\nCreated folder!\作成したフォルダ!\n\n bakafiles");cload("core/system/dir.php?dir=' . $_POST['cre_new_dir_last_dir'] . '");</script>';
111+
}
112+
}
113+
function deleteDirectory($dir)
114+
{
115+
if (!file_exists($dir)) {
116+
return true;
117+
}
118+
119+
if (!is_dir($dir)) {
120+
return unlink($dir);
121+
}
122+
123+
foreach (scandir($dir) as $item) {
124+
if ($item == '.' || $item == '..') {
125+
continue;
126+
}
127+
128+
if (!deleteDirectory($dir . DIRECTORY_SEPARATOR . $item)) {
129+
return false;
130+
}
131+
}
132+
133+
return rmdir($dir);
134+
}
60135
if (isset($_FILES['file'], $_POST['upload_dir'])) {
61136
if ($_FILES['file'] == null) {
62137
echo 'Vui lòng chọn file :<\nPlease select a file :<\n\n bakafiles';
@@ -67,3 +142,15 @@ function mime_mdicon($dir)
67142
echo "Đã up thành công! - Uploaded!";
68143
}
69144
}
145+
if (isset($_GET['download'], $_GET['dird'])) {
146+
$file__dir = $_GET['dird'];
147+
if (strpos(mime_content_type(ROOT_DIR . "/" . $file__dir), "image/") === false) {
148+
echo "Error: This file is not an image! >_< - đây khum phải là file ảnh :<";
149+
} else {
150+
header('Content-Type: application/octet-stream');
151+
header("Content-Transfer-Encoding: Binary");
152+
header("Content-disposition: attachment; filename=\"" . basename($file__dir) . "\"");
153+
readfile(ROOT_DIR . "/" . $file__dir);
154+
exit;
155+
}
156+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
/* bakafiles >~<
3+
by Michio Nakano (michio.xd)
4+
5+
License: GNU GENERAL PUBLIC LICENSE (GPL)
6+
7+
https://github.com/michioxd/bakafiles
8+
9+
File: server.php
10+
*/
11+
12+
// locate lastest version
13+
define("UPDATE_SERVER", "http://michio.ga/cgi-bin/bakafiles_res/client-get/main.aspx?GetCurrentVersion=yes");
14+
15+
// release core
16+
define("UPDATE_RELEASE", "http://release.michio.ga/bakafiles/updates");

core/system/play.php

Lines changed: 53 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,44 +10,57 @@
1010
*/
1111
require __DIR__ . '/kernel/sys.php';
1212
if (isset($_GET['dir'])) {
13-
if (file_exists(ROOT_DIR . "/" . $_GET['dir']) == false) { ?>
14-
<div style="text-align:center">
15-
<span style="font-size: 140px;" class="material-icons">
16-
warning
17-
</span>
18-
<h4>This dir is empty :((</h4>
19-
</div>
20-
<?php } else {
21-
22-
?>
23-
<div class="dir-badge mdl-card mdl-shadow--2dp">
24-
<?php
25-
if (isset($_GET['dir'])) {
26-
if ($_GET['dir'] != "/" or $_GET['dir'] != null) { ?>
27-
<button class="link-click mdl-button mdl-js-button mdl-js-ripple-effect" data-href="core/system/dir.php?dir=<?php echo urlencode($_GET['dir'] . "/.."); ?>" style="float: left;">
28-
<span class="material-icons">
29-
arrow_back_ios
30-
</span>
31-
<div class="rippleJS"></div>
32-
</button>
33-
<?php }
34-
} ?>
35-
<a class="inndeexx link-click" data-href="core/system/dir.php" href="#"><i class="material-icons">home</i> (home) /</a>
36-
<?php
37-
if (isset($_GET['dir'])) {
38-
if ($_GET['dir'] != "/" or $_GET['dir'] != null) {
39-
$forrr = explode("/", $_GET['dir']);
40-
foreach ($forrr as $dir_badge) { ?>
41-
<a><?php if ($dir_badge != null) {
42-
echo str_replace("../", "", $dir_badge . "/");
43-
}; ?></a>
44-
<?php }
45-
}
46-
} ?>
47-
</div>
48-
<video style="width:100%;border:none">
49-
<source type="video/mp4" src="<?php echo "/" . $_GET['dir']; ?>">
50-
</video>
51-
<script src="js/page.js"></script>
52-
<?php }
13+
if ($_GET['dir'] == "/" or $_GET['dir'] == null) {
14+
$main_path = ROOT_DIR . "/";
15+
} else {
16+
$main_path = ROOT_DIR . "/" . $_GET['dir'];
17+
}
18+
} else {
19+
$main_path = ROOT_DIR . "/";
20+
}
21+
$all__files = scandir(dirname($main_path, 1));
22+
$all__files = array_diff(scandir(dirname($main_path, 1)), array('.', '..'));
23+
if (strpos(mime_content_type($main_path), "video/") === false) {
24+
echo "Error: This file is not an video! >_< - đây khum phải là file video :<";
25+
exit();
5326
}
27+
?>
28+
<div class="dir-badge mdl-card mdl-shadow--2dp">
29+
<?php
30+
if (isset($_GET['dir'])) {
31+
if ($_GET['dir'] != null or $_GET['dir'] != "") { ?>
32+
<button class="link-click mdl-button mdl-js-button mdl-js-ripple-effect" data-href="core/system/dir.php?dir=<?php
33+
if (urlencode(dirname($_GET['dir'], 1)) == "." or $_GET['dir'] == '%2f') {
34+
echo "";
35+
} else {
36+
echo urlencode(dirname($_GET['dir'], 1));
37+
} ?>" style="float: left;">
38+
<span class="material-icons">
39+
arrow_back_ios
40+
</span>
41+
<div class="rippleJS"></div>
42+
</button>
43+
<?php }
44+
} ?>
45+
<a class="inndeexx link-click" data-href="core/system/dir.php" href="#"><i class="material-icons">home</i> (root)/</a>
46+
<?php
47+
if (isset($_GET['dir'])) {
48+
if ($_GET['dir'] != "/" or $_GET['dir'] != null) {
49+
$forrr = explode("/", $_GET['dir']);
50+
foreach ($forrr as $dir_badge) { ?>
51+
<a><?php if ($dir_badge != null) {
52+
echo str_replace("../", "", $dir_badge . "/");
53+
}; ?></a>
54+
<?php }
55+
}
56+
} ?>
57+
</div>
58+
<?php
59+
if (strpos(mime_content_type($main_path), "video/") === false) {
60+
echo "Error: This file is not an video! >_< - đây khum phải là file video :<";
61+
} else { ?>
62+
<video style="width:100%;border:none" controls autoplay>
63+
<source type="video/mp4" src="<?php echo "/" . $_GET['dir']; ?>">
64+
</video>
65+
<?php } ?>
66+
<script src="js/page.js"></script>

core/system/preview.php

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
require __DIR__ . '/kernel/sys.php';
3+
if (isset($_GET['dir'])) {
4+
if ($_GET['dir'] == "/" or $_GET['dir'] == null) {
5+
$main_path = ROOT_DIR . "/";
6+
} else {
7+
$main_path = ROOT_DIR . "/" . $_GET['dir'];
8+
}
9+
} else {
10+
$main_path = ROOT_DIR . "/";
11+
}
12+
$all__files = scandir(dirname($main_path, 1));
13+
$all__files = array_diff(scandir(dirname($main_path, 1)), array('.', '..'));
14+
if (strpos(mime_content_type($main_path), "image/") === false) {
15+
echo "Error: This file is not an image! >_< - đây khum phải là file ảnh :<";
16+
}
17+
?>
18+
<div class="dir-badge mdl-card mdl-shadow--2dp">
19+
<?php
20+
if (isset($_GET['dir'])) {
21+
if ($_GET['dir'] != null or $_GET['dir'] != "") { ?>
22+
<button class="link-click mdl-button mdl-js-button mdl-js-ripple-effect" data-href="core/system/dir.php?dir=<?php
23+
if (urlencode(dirname($_GET['dir'], 1)) == "." or $_GET['dir'] == '%2f') {
24+
echo "";
25+
} else {
26+
echo urlencode(dirname($_GET['dir'], 1));
27+
} ?>" style="float: left;">
28+
<span class="material-icons">
29+
arrow_back_ios
30+
</span>
31+
<div class="rippleJS"></div>
32+
</button>
33+
<?php }
34+
} ?>
35+
<a class="inndeexx link-click" data-href="core/system/dir.php" href="#"><i class="material-icons">home</i> (root)/</a>
36+
<?php
37+
if (isset($_GET['dir'])) {
38+
if ($_GET['dir'] != "/" or $_GET['dir'] != null) {
39+
$forrr = explode("/", $_GET['dir']);
40+
foreach ($forrr as $dir_badge) { ?>
41+
<a><?php if ($dir_badge != null) {
42+
echo str_replace("../", "", $dir_badge . "/");
43+
}; ?></a>
44+
<?php }
45+
}
46+
} ?>
47+
</div>
48+
<h4 style="margin:20px"><?php echo basename($main_path); ?><p style="color:gray !important;font-weight:bold;margin:7px;float:right;font-size:12px">FILE SIZE: <?php echo load_file_size($main_path); ?></p>
49+
</h4>
50+
<div class="main-image-preview">
51+
52+
<img src="<?php echo load_image_b64($main_path); ?>" alt="" class="main-image-preview__image">
53+
</div>
54+
<button class="lbd mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect mdl-button--raised mdl-button--colored">
55+
So laggy? Load by dir <div class="rippleJS"></div>
56+
</button>
57+
<button onclick="window.location.href='?download&dird=<?php echo urlencode($_GET['dir']); ?>'" class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect mdl-button--raised mdl-button--colored">
58+
<span class="material-icons">
59+
file_download
60+
</span>
61+
Download <div class="rippleJS"></div>
62+
</button>
63+
<script>
64+
$('.lbd').click(function() {
65+
$('.main-image-preview__image').attr("src", "<?php echo '/' . $_GET['dir']; ?>");
66+
$('.lbd').remove();
67+
})
68+
</script>
69+
<script src="js/page.js"></script>

core/ui/footer.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
</div>
2020
<script src="js/page.js"></script>
2121
<script src="js/main.js"></script>
22+
<script>
23+
$(document).ready(function() {
24+
cload("core/system/dir.php");
25+
});
26+
</script>
2227
<script async src="https://cdn.jsdelivr.net/npm/vanilla-ripplejs@1.0.6" integrity="sha384-OlarGErerEgz/M7123pQTTek4pUIiR6t0BK09bTmWDi2cZYbv3VHrriaXDnA0Oup" crossorigin="anonymous"></script>
2328
</body>
2429

0 commit comments

Comments
 (0)