2020-09-16 12:24:54 +08:00
|
|
|
<?php
|
|
|
|
function ___sortcmp()
|
|
|
|
{
|
|
|
|
$a = func_get_arg(0);
|
|
|
|
$b = func_get_arg(1);
|
|
|
|
return strcasecmp($a, $b);
|
|
|
|
}
|
|
|
|
|
|
|
|
function ___codepre()
|
|
|
|
{
|
|
|
|
$str = func_get_arg(0);
|
|
|
|
if (func_num_args() > 1) {
|
|
|
|
$arr1 = array("&", "\"", "'", "<", ">", '"');
|
|
|
|
$arr2 = array("&", """, "'", "<", ">", "'");
|
|
|
|
} else {
|
|
|
|
$arr1 = array("&", "\"", "'", "<", ">", " ", '"');
|
|
|
|
$arr2 = array("&", """, "'", "<", ">", " ", "'");
|
|
|
|
}
|
|
|
|
return str_replace($arr1, $arr2, $str);
|
|
|
|
}
|
|
|
|
|
|
|
|
function ___ziplist()
|
|
|
|
{
|
|
|
|
$zip = trim(func_get_arg(0));
|
2020-10-21 20:18:22 +08:00
|
|
|
if (!is_readable('pclzip.php') || !___getmime($zip, 'zip')) {
|
|
|
|
return false;
|
|
|
|
}
|
2020-09-16 12:24:54 +08:00
|
|
|
require 'pclzip.php';
|
|
|
|
$pclzip = new pclzip($zip);
|
2020-10-21 20:18:22 +08:00
|
|
|
if (!($getlist = $pclzip->listContent())) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!is_array($getlist) || count($getlist) < 1) {
|
|
|
|
return false;
|
|
|
|
}
|
2020-09-16 12:24:54 +08:00
|
|
|
return $getlist;
|
|
|
|
}
|
|
|
|
|
|
|
|
function ___convert()
|
|
|
|
{
|
|
|
|
$str = func_get_arg(0);
|
2020-10-21 20:18:22 +08:00
|
|
|
if (!function_exists("mb_convert_encoding")) {
|
|
|
|
return $str;
|
|
|
|
}
|
2020-09-16 12:24:54 +08:00
|
|
|
$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);
|
|
|
|
}
|
2020-10-21 20:18:22 +08:00
|
|
|
if (!is_file($path)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!($fp = fopen($path, "rb"))) {
|
|
|
|
return false;
|
|
|
|
}
|
2020-09-16 12:24:54 +08:00
|
|
|
$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)) {
|
2020-10-21 20:18:22 +08:00
|
|
|
if (!is_file($fs[$i]) || !is_readable($fs[$i])) {
|
|
|
|
continue;
|
|
|
|
}
|
2020-09-16 12:24:54 +08:00
|
|
|
$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.xyz 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];
|
|
|
|
}
|
|
|
|
if (isset($_SERVER['HTTP_RANGE'])) {
|
|
|
|
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);
|
2020-10-21 20:18:22 +08:00
|
|
|
if (!is_link($path)) {
|
|
|
|
return realpath($path);
|
|
|
|
}
|
2020-09-16 12:24:54 +08:00
|
|
|
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));
|
2020-10-21 20:18:22 +08:00
|
|
|
if (php_uname("s") != "Linux") {
|
|
|
|
return false;
|
|
|
|
}
|
2020-09-16 12:24:54 +08:00
|
|
|
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')) {
|
2020-10-21 20:18:22 +08:00
|
|
|
if (mb_strlen($path, "UTF-8") <= 18) {
|
|
|
|
return $path;
|
|
|
|
}
|
2020-09-16 12:24:54 +08:00
|
|
|
} else {
|
2020-10-21 20:18:22 +08:00
|
|
|
if (strlen($path) <= 18) {
|
|
|
|
return $path;
|
|
|
|
}
|
2020-09-16 12:24:54 +08:00
|
|
|
}
|
|
|
|
$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;
|
|
|
|
}
|
|
|
|
|
|
|
|
function ___windowsdisk()
|
|
|
|
{
|
|
|
|
$disks = array();
|
|
|
|
foreach (range('A', 'Z') as $item) {
|
|
|
|
$item = sprintf("%s:\\", $item);
|
|
|
|
if (is_dir($item)) {
|
|
|
|
$disks[] = $item;
|
|
|
|
}
|
|
|
|
}
|
2020-10-21 20:18:22 +08:00
|
|
|
if (empty($disks)) {
|
|
|
|
return false;
|
|
|
|
}
|
2020-09-16 12:24:54 +08:00
|
|
|
return $disks;
|
|
|
|
}
|
2020-10-21 20:18:22 +08:00
|
|
|
?>
|