Commit ea8af73c authored by Medicean's avatar Medicean

(Enhance: Core/CMDLINUX) upload file 不再只依赖xxd

parent 403b4636
......@@ -6,16 +6,16 @@
module.exports = () => ({
info: {
_: `ACWD=$(pwd);
AUNAME=$(uname -a);
AUSER=$(whoami);
echo -n "$ACWD\\t/\\t$AUNAME\\t$AUSER";`
AUNAME=$(uname -a);
AUSER=$(whoami);
echo -n "$ACWD\\t/\\t$AUNAME\\t$AUSER";`
},
probedb: { // 检测数据库函数支持
_: `command_exists() { command -v "$@" > /dev/null 2>&1; };
DBLIST="mysql psql sqlite3";
for v in $DBLIST
do
if command_exists $v; then echo "$v\\t1"; else echo "$v\\t0"; fi;
done;`
DBLIST="mysql psql sqlite3";
for v in $DBLIST
do
if command_exists $v; then echo "$v\\t1"; else echo "$v\\t0"; fi;
done;`
}
})
\ No newline at end of file
......@@ -31,7 +31,17 @@ if [ $? = 0 ]; then echo -n 1; else echo -n 0; fi;`
},
upload_file: {
_: `echo #{buffer::content}|xxd -r -p >> #{path} && echo -n 1||echo -n 0;`
_: `command_exists() { command -v "$@" > /dev/null 2>&1; };
ACONTENT="#{buffer::content}";
ADSTPATH="#{path}";
if command_exists xxd; then
echo -n $ACONTENT|xxd -r -p >> $ADSTPATH && echo -n 1||echo -n 0;
elif command_exists python3; then
echo -n $ACONTENT|python3 -c "import sys, binascii; sys.stdout.buffer.write(binascii.unhexlify(input().strip()))">>$ADSTPATH && echo -n 1||echo -n 0;
else
echo -n $ACONTENT|sed 's/\\([0-9A-F]\\{2\}\\)/\\\\\\\\\\\\x\\1/gI'|xargs printf>>$ADSTPATH && echo -n 1||echo -n 0;
fi;
`
},
rename: {
......@@ -52,15 +62,15 @@ if [ $? = 0 ]; then echo -n 1; else echo -n 0; fi;`
wget: {
_: `command_exists() { command -v "$@" > /dev/null 2>&1; };
ascurl=''
if command_exists curl; then
ascurl='curl -ksSL -o';
elif command_exists wget; then
ascurl='wget --no-check-certificate -qO';
elif command_exists busybox && busybox --list-modules | grep -q wget; then
ascurl='busybox wget --no-check-certificate -qO'
fi;
$ascurl #{path} #{url} && echo -n 1||echo -n 0;
ascurl=''
if command_exists curl; then
ascurl='curl -ksSL -o';
elif command_exists wget; then
ascurl='wget --no-check-certificate -qO';
elif command_exists busybox && busybox --list-modules | grep -q wget; then
ascurl='busybox wget --no-check-certificate -qO'
fi;
$ascurl #{path} #{url} && echo -n 1||echo -n 0;
`
}
})
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment