
@ -1,6 +0,0 @@
|
||||
text = synOCR |
||||
description = synOCR |
||||
icon_16 = images/synOCR_16.png |
||||
icon_32 = images/synOCR_32.png |
||||
type = embedded |
||||
path = /webman/3rdparty/synOCR/index.cgi |
@ -0,0 +1,2 @@
|
||||
#!/bin/sh |
||||
/var/packages/synOCR/scripts/start-stop-status "$@" |
@ -1,58 +0,0 @@
|
||||
<?PHP |
||||
//***********************************************************************// |
||||
// check_appprivilege.inc.php // |
||||
// Description: Script to query the active user permission for the // |
||||
// called application. // |
||||
// This will allow control of the permissions for // |
||||
// 3rdparty apps via Control Panel - Permissions // |
||||
// Now with query from SynoToken (DSM 4.x and onward) // |
||||
// Author: QTip from the german Synology support forum // |
||||
// Copyright: 2014-2016 by QTip // |
||||
// License: GNU GPLv3 (see LICENSE) // |
||||
// Thanks to MrSandman (German Synology support forum) for the nudge in // |
||||
// the right direction // |
||||
// ------------------------------------------------------------------- // |
||||
// Version: 0.31 - 18/09/2016 // |
||||
//***********************************************************************// |
||||
function check_privilege($appname) { |
||||
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])){ |
||||
$clientIP = $_SERVER['HTTP_X_FORWARDED_FOR']; |
||||
} elseif (isset($_SERVER['HTTP_X_REAL_IP'])){ |
||||
$clientIP = $_SERVER['HTTP_X_REAL_IP']; |
||||
} else { |
||||
$clientIP = $_SERVER['REMOTE_ADDR']; |
||||
} |
||||
putenv('HTTP_COOKIE='.$_SERVER['HTTP_COOKIE']); |
||||
putenv('REMOTE_ADDR='.$clientIP); |
||||
$login = shell_exec("/usr/syno/synoman/webman/login.cgi"); |
||||
preg_match('/\"SynoToken\"\s*?:\s*?\"(.*)\"/',$login,$synotoken); |
||||
$synotoken = trim($synotoken[1]); |
||||
// backup the current state of QUERY_STRING |
||||
$tmpenv = getenv('QUERY_STRING'); |
||||
putenv('QUERY_STRING=SynoToken='.$synotoken); |
||||
$synouser = shell_exec("/usr/syno/synoman/webman/modules/authenticate.cgi"); |
||||
if ($synouser == '') return array('','',0); |
||||
|
||||
// get dsm build |
||||
$dsmbuild = shell_exec("/bin/get_key_value /etc.defaults/VERSION buildnumber"); |
||||
if ($dsmbuild >= 7307) { |
||||
$raw_data = shell_exec("/usr/syno/bin/synowebapi --exec api=SYNO.Core.Desktop.Initdata method=get version=1 runner=".$synouser); |
||||
$initdata = json_decode(trim($raw_data),true); |
||||
$appprivilege = (array_key_exists($appname, $initdata['data']['AppPrivilege']) && $initdata['data']['AppPrivilege'][$appname]) ? 1 : 0; |
||||
$is_admin = (array_key_exists('is_admin', $initdata['data']['Session']) && $initdata['data']['Session']['is_admin'] == 1) ? 1 : 0; |
||||
} else { |
||||
$raw_data = shell_exec("/usr/syno/synoman/webman/initdata.cgi"); |
||||
$raw_data = substr($raw_data,strpos($raw_data,"{")-1); |
||||
$initdata = json_decode(trim($raw_data),true); |
||||
$appprivilege = (array_key_exists($appname, $initdata['AppPrivilege']) && $initdata['AppPrivilege'][$appname]) ? 1 : 0; |
||||
$is_admin = (array_key_exists('is_admin', $initdata['Session']) && $initdata['Session']['is_admin'] == 1) ? 1 : 0; |
||||
} |
||||
// print $synotoken." - ".$synouser." - ".$is_admin; |
||||
// if application not found or user not admin, return empty string |
||||
// restore the old state of QUERY_STRING |
||||
putenv('QUERY_STRING='.$tmpenv); |
||||
if (!$appprivilege && !$is_admin) return array('','',0); |
||||
return array($synotoken,$synouser,$is_admin); |
||||
} |
||||
?> |
||||
|
@ -1,52 +0,0 @@
|
||||
#!/bin/sh |
||||
|
||||
# Sprachvariablen laden (function by Ultimate Backup) |
||||
function language() |
||||
{ |
||||
# Englische Sprachdatei laden |
||||
source "lang/lang_enu.txt" |
||||
|
||||
# Sprachdateien konfigurieren |
||||
# Funktion zur Ermittlung der eingestellten Sprache |
||||
# - DSM Sprache ermitteln (aus synoinfo.conf) |
||||
# - Browser Sprache ermitteln (aus ${HTTP_ACCEPT_LANGUAGE}) |
||||
# - wenn DSM Sprache = default, dann benutze Browser Sprache |
||||
# - Persönliche DSM Sprache ermitteln (aus usersettings) |
||||
# - falls Persönliche DSM Sprache = default, dann benutze weiterhin die zuvor |
||||
# ermittelte Sprache, ansonsten benutze die ermittelte Persönliche DSM Sprache |
||||
# - ist DSM Sprache und Persönliche DSM Sprache = "def" und Browser Sprache nicht gesetzt, dann benutze Standard Sprache (DEFLANG) |
||||
# Prioritäten: 1. Persönliche DSM Sprache =2. DSM Sprache =3. Browser Sprache =4. Standard Sprache |
||||
# |
||||
|
||||
# Übersetzungstabelle deklarieren |
||||
declare -A ISO2SYNO |
||||
ISO2SYNO=( ["de"]="ger" ["en"]="enu" ["zh"]="chs" ["cs"]="csy" ["jp"]="jpn" ["ko"]="krn" ["da"]="dan" ["fr"]="fre" ["it"]="ita" ["nl"]="nld" ["no"]="nor" ["pl"]="plk" ["ru"]="rus" ["sp"]="spn" ["sv"]="sve" ["hu"]="hun" ["tr"]="trk" ["pt"]="ptg" ) |
||||
|
||||
# DSM Sprache ermitteln |
||||
deflang="ger" |
||||
lang=$(cat /etc/synoinfo.conf | grep language | sed 's/language=//;s/\"//g' | egrep -o "^.{3}") |
||||
|
||||
if [[ "${lang}" == "def" ]] ; then |
||||
# Browsersprache ermitteln |
||||
if [ -n "${HTTP_ACCEPT_LANGUAGE}" ] ; then |
||||
bl=$(echo ${HTTP_ACCEPT_LANGUAGE} | cut -d "," -f1) |
||||
bl=${bl:0:2} |
||||
lang=${ISO2SYNO[${bl}]} |
||||
else |
||||
lang=${deflang} |
||||
fi |
||||
fi |
||||
# Persönliche DSM Sprache ermitteln |
||||
usersettingsfile=/usr/syno/etc/preference/${login_user}/usersettings |
||||
if [ -f ${usersettingsfile} ] ; then |
||||
userlanguage=$(jq -r ".Personal.lang" ${usersettingsfile}) |
||||
if [ -n "${userlanguage}" -a "${userlanguage}" != "def" -a "${userlanguage}" != "null" ] ; then |
||||
lang=${userlanguage} |
||||
fi |
||||
fi |
||||
|
||||
# Sprachdatei laden |
||||
if [ -f "lang/lang_${lang}.txt" ] && [[ "$lang" != "enu" ]]; then |
||||
source "lang/lang_${lang}.txt" |
||||
fi |
||||
} |
@ -1,11 +0,0 @@
|
||||
<?php require('includes/check_privilege.inc.php'); list($synotoken, |
||||
$synouser, $is_admin) = |
||||
check_privilege('SYNO.SDS.synOCR.Application'); if ($synouser == '') |
||||
{ |
||||
echo "0"; |
||||
} |
||||
else |
||||
{ |
||||
echo "token: $synotoken user: $synouser admin: $is_admin"; |
||||
} |
||||
?> |
@ -1,227 +0,0 @@
|
||||
#!/bin/bash |
||||
# /usr/syno/synoman/webman/3rdparty/synOCR/index.cgi |
||||
|
||||
# adjust PATH: |
||||
machinetyp=$(uname --machine) |
||||
if [ $machinetyp = "x86_64" ]; then |
||||
PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/syno/bin:/usr/syno/sbin:/usr/local/bin:/opt/usr/bin:/usr/syno/synoman/webman/3rdparty/synOCR/bin |
||||
elif [ $machinetyp = "aarch64" ]; then |
||||
PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/syno/bin:/usr/syno/sbin:/usr/local/bin:/opt/usr/bin:/usr/syno/synoman/webman/3rdparty/synOCR/bin_aarch64 |
||||
fi |
||||
|
||||
# Check access authorizations of the DSM (Syno-Token) |
||||
login=$(php -f /volume*/@appstore/synOCR/includes/token.php) || exit |
||||
login_user=$(echo $login | sed "s/.*user: //;s/ admin:.*//") || exit |
||||
login_admin=$(echo $login | sed -e 's/.*admin: //') || exit |
||||
if [ -n "$login" ]; then |
||||
if [[ "$login" != "0" ]] && [[ "$login_user" != "0" ]]; then |
||||
access="yes" |
||||
fi |
||||
fi |
||||
|
||||
# Exit script if access not granted |
||||
if [ -z "$access" ]; then |
||||
exit |
||||
else |
||||
# Initiate user folder |
||||
dir=$(echo /volume*/@appstore/synOCR) || exit |
||||
get_var=$(which get_key_value) || exit |
||||
set_var=$(which synosetkeyvalue) || exit |
||||
usersettings="$dir/usersettings" # ToDo: move to "$dir/etc" |
||||
if [ ! -d "$usersettings" ]; then |
||||
mkdir "$usersettings" |
||||
fi |
||||
var="$dir/usersettings/var.txt" |
||||
|
||||
# var="$usersettings/var.txt" |
||||
# stop="$usersettings/stop.txt" |
||||
stop="$dir/usersettings/stop.txt" |
||||
black="color: #000000" |
||||
green="color: #00B10D" |
||||
red="color: #DF0101" |
||||
synotrred="color: #BD0010" |
||||
synocrred="color: #BD0010" |
||||
blue="color: #2A588C" |
||||
orange="color: #FFA500" |
||||
grey="color: #424242" |
||||
grey1="color: #53657D" |
||||
grey2="color: #374355" |
||||
|
||||
# Load configuration: |
||||
# source $dir/app/etc/Konfiguration.txt |
||||
|
||||
# read MAC-adress (only to hide DEV pages) |
||||
read MAC </sys/class/net/eth0/address |
||||
sysID=`echo $MAC | cksum | awk '{print $1}'`; sysID="$(printf '%010d' $sysID)" #echo "Prüfsumme der MAC-Adresse als Hardware-ID: $sysID" 10-stellig |
||||
fi |
||||
|
||||
source $dir/includes/functions.sh |
||||
|
||||
# Load language variables: |
||||
language |
||||
|
||||
if [ -z "$backifs" ]; then |
||||
backifs="$IFS" |
||||
readonly backifs |
||||
fi |
||||
|
||||
IFS="&" |
||||
set -- $QUERY_STRING |
||||
IFS=' |
||||
' |
||||
|
||||
# Initiate environment parameters: |
||||
for i in "$@"; do |
||||
IFS="$backifs" |
||||
variable=${i%%=*} |
||||
encode_value=${i##*=} |
||||
decode_value=$(echo "$encode_value" | sed -f $dir/includes/decode.sed) |
||||
"$set_var" "$var" "$variable" "$decode_value" |
||||
"$set_var" "$var" "encode_$variable" "$encode_value" |
||||
done |
||||
|
||||
if [ -f "$var" ]; then |
||||
source "$var" |
||||
fi |
||||
|
||||
mainpage=${page%%-*} |
||||
site=${page##*-} |
||||
sitemore=$(( $site + 1 )) |
||||
siteless=$(( $site - 1 )) |
||||
|
||||
if [[ "$mainpage" == "start" ]]; then |
||||
[ -f "$var" ] && rm "$var" |
||||
[ -f "$stop" ] && rm "$stop" |
||||
[ -f "$usersettings/stop2.txt" ] && rm "$usersettings/stop2.txt" |
||||
mainpage="main" |
||||
fi |
||||
|
||||
# Layout - Define Home Page: |
||||
if [ -z "$page" ]; then |
||||
mainpage="main" |
||||
fi |
||||
|
||||
"$set_var" "$var" "page" "" |
||||
|
||||
# Layout - Open basic framework incl. navigation - |
||||
echo "Content-type: text/html" |
||||
echo |
||||
echo ' |
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
||||
<html xmlns="http://www.w3.org/1999/xhtml"> |
||||
<head> |
||||
<title>synOCR</title> |
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
||||
<meta name="viewport" content="width=device-width, initial-scale=1"> |
||||
|
||||
<link rel="icon" type="image/svg+xml" href="images/synOCR-LOGO.svg" sizes="any"> |
||||
<!-- <link rel="shortcut icon" href="images/uh_32.png" type="image/x-icon" /> --> |
||||
<link rel="stylesheet" type="text/css" href="includes/synocr_1.1.0.css" /> |
||||
<!--Load the AJAX API--> |
||||
<!--<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>--> |
||||
<script type="text/javascript" src="js/chartsloader.js"></script> |
||||
</head> |
||||
<body>' |
||||
|
||||
echo '<div id="wrapper">' |
||||
echo ' |
||||
<div id="navleft"> |
||||
<div id="navleftinbox"> |
||||
<ul class="li_blank">' |
||||
|
||||
# old main-Page: |
||||
if [[ "$mainpage" == "main" ]]; then |
||||
echo ' |
||||
<li><a class="navitemselc" href="index.cgi?page=main"><img class="svg" src="images/home_white@geimist.svg" height="25" width="25"/>'$lang_page1'</a></li>' |
||||
else |
||||
echo ' |
||||
<li><a class="navitem" href="index.cgi?page=main"><img class="svg" src="images/home_grey3@geimist.svg" height="25" width="25"/>'$lang_page1'</a></li>' |
||||
fi |
||||
|
||||
if [[ "$mainpage" == "edit" ]]; then |
||||
echo ' |
||||
<li><a class="navitemselc" href="index.cgi?page=edit"><img class="svg" src="images/settings_white@geimist.svg" height="25" width="25"/>'$lang_page2'</a></li>' |
||||
else |
||||
echo ' |
||||
<li><a class="navitem" href="index.cgi?page=edit"><img class="svg" src="images/settings_grey3@geimist.svg" height="25" width="25"/>'$lang_page2'</a></li>' |
||||
fi |
||||
|
||||
if [[ "$mainpage" == "timer" ]] && [[ $(synogetkeyvalue /etc.defaults/VERSION majorversion) -lt 7 ]]; then |
||||
echo ' |
||||
<li><a class="navitemselc" href="index.cgi?page=timer"><img class="svg" src="images/calendar_white@geimist.svg" height="25" width="25"/>'$lang_page3'</a></li>' |
||||
elif [[ $(synogetkeyvalue /etc.defaults/VERSION majorversion) -lt 7 ]]; then |
||||
echo ' |
||||
<li><a class="navitem" href="index.cgi?page=timer"><img class="svg" src="images/calendar_grey3@geimist.svg" height="25" width="25"/>'$lang_page3'</a></li>' |
||||
fi |
||||
|
||||
if [[ "$mainpage" == "help" ]]; then |
||||
echo ' |
||||
<li><a class="navitemselc" href="index.cgi?page=help"><img class="svg" src="images/help_white@geimist.svg" height="25" width="25"/>'$lang_page4'</a></li>' |
||||
else |
||||
echo ' |
||||
<li><a class="navitem" href="index.cgi?page=help"><img class="svg" src="images/help_grey3@geimist.svg" height="25" width="25"/>'$lang_page4'</a></li>' |
||||
fi |
||||
|
||||
echo '</ul> |
||||
</div> |
||||
</div>' |
||||
|
||||
echo ' |
||||
<p style="padding: 15px;"> |
||||
<div class="clear"></div>' |
||||
|
||||
# Layout - Dynamic page exchange: |
||||
echo ' |
||||
<form action="index.cgi" method="get" autocomplete="on">' |
||||
|
||||
if [ -z "$mainpage" ]; then |
||||
echo 'The page could not be found!' |
||||
else |
||||
script="$mainpage.sh" |
||||
if [ -f "$script" ]; then |
||||
. ./"$script" |
||||
else |
||||
. ./main.sh |
||||
fi |
||||
fi |
||||
|
||||
# Error output: |
||||
if [ -f "$usersettings/stop2.txt" ]; then |
||||
#<div id="Content_1Col"> |
||||
echo ' |
||||
<div class="Content_1Col_full"> |
||||
<div class="warning"> |
||||
<p class="center">' |
||||
IFS=' |
||||
' |
||||
for i in $(< "$usersettings/stop2.txt"); do |
||||
IFS="$backifs" |
||||
echo ''$i'' |
||||
done |
||||
[ -f "$stop" ] && rm "$stop" |
||||
[ -f "$usersettings/stop2.txt" ] && rm "$usersettings/stop2.txt" |
||||
echo ' |
||||
</p> |
||||
</div> |
||||
<div id="lastLine"></div> |
||||
</div><div class="clear"></div>' |
||||
#</div> |
||||
fi |
||||
|
||||
if [ -f "$stop" ]; then |
||||
cp "$stop" "$usersettings/stop2.txt" |
||||
echo '<meta http-equiv="refresh" content="0; url=index.cgi?page='$(echo "$page" | sed 's/[[:digit:]]*$//')''$siteless'#lastLine">' |
||||
fi |
||||
|
||||
# Footer |
||||
if [ -f "footer.sh" ] && [ ! -f "$stop" ]; then |
||||
. ./footer.sh |
||||
fi |
||||
|
||||
# Layout - Close base frame - |
||||
echo ' |
||||
</form> |
||||
</div> |
||||
</body> |
||||
</html>' |
@ -0,0 +1,20 @@
|
||||
{ |
||||
".url": { |
||||
"SYNO.SDS.ThirdParty.App.synOCR": { |
||||
"type": "legacy", |
||||
"title": "synOCR", |
||||
"desc": "synOCR", |
||||
"allUsers": false, |
||||
"allowMultiInstance": false, |
||||
"grantPrivilege": "all", |
||||
"advanceGrantPrivilege": true, |
||||
"configablePrivilege": true, |
||||
"icon": "images/synOCR_{0}.png", |
||||
"appWindow": "SYNO.SDS.ThirdParty.App.synOCR", |
||||
"texts": "texts", |
||||
"width": 992, |
||||
"height": 560, |
||||
"url": "/webman/3rdparty/synOCR/index.cgi" |
||||
} |
||||
} |
||||
} |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 7.5 KiB |
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.0 KiB |
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 7.3 KiB |
Before Width: | Height: | Size: 857 B After Width: | Height: | Size: 857 B |
Before Width: | Height: | Size: 855 B After Width: | Height: | Size: 855 B |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 676 B After Width: | Height: | Size: 676 B |
Before Width: | Height: | Size: 591 B After Width: | Height: | Size: 591 B |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 9.4 KiB |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 953 B After Width: | Height: | Size: 953 B |
Before Width: | Height: | Size: 200 KiB After Width: | Height: | Size: 200 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 118 KiB After Width: | Height: | Size: 118 KiB |
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 8.8 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 7.5 KiB |
After Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 7.3 KiB |
After Width: | Height: | Size: 857 B |
After Width: | Height: | Size: 855 B |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 2.5 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 9.4 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 953 B |
After Width: | Height: | Size: 566 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 4.5 KiB |
After Width: | Height: | Size: 37 KiB |
After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 6.8 KiB |
After Width: | Height: | Size: 83 KiB |
After Width: | Height: | Size: 8.5 KiB |
After Width: | Height: | Size: 9.3 KiB |
After Width: | Height: | Size: 11 KiB |
@ -0,0 +1,93 @@
|
||||
#!/bin/bash |
||||
|
||||
# ---------------------------------------------------------------------- # |
||||
# native URL encode & decode: |
||||
# https://gist.github.com/cdown/1163649 |
||||
urlencode() { |
||||
# urlencode <string> |
||||
old_lc_collate=$LC_COLLATE |
||||
LC_COLLATE=C |
||||
|
||||
local length="${#1}" |
||||
for (( i = 0; i < length; i++ )); do |
||||
local c="${1:$i:1}" |
||||
case $c in |
||||
[a-zA-Z0-9.~_-]) printf '%s' "$c" ;; |
||||
*) printf '%%%02X' "'$c" ;; |
||||
esac |
||||
done |
||||
|
||||
LC_COLLATE=$old_lc_collate |
||||
} |
||||
|
||||
urldecode() { |
||||
# urldecode <string> |
||||
local url_encoded="${1//+/ }" |
||||
printf '%b' "${url_encoded//%/\\x}" |
||||
} |
||||
|
||||
# ---------------------------------------------------------------------- # |
||||
function language() { |
||||
# ---------------------------------------------------------------------- # |
||||
# Spracheinstellungen konfigurieren # |
||||
# ---------------------------------------------------------------------- # |
||||
# Englische Sprachdatei laden |
||||
source "lang/lang_enu.txt" |
||||
|
||||
#********************************************************************# |
||||
# Description: Script get the current used dsm language # |
||||
# Author: QTip from the german Synology support forum # |
||||
# Copyright: 2016-2018 by QTip # |
||||
# License: GNU GPLv3 # |
||||
# ---------------------------------------------------------------- # |
||||
# Version: 0.15 - 11/06/2018 # |
||||
#********************************************************************# |
||||
|
||||
# Sprachdateien konfigurieren |
||||
# Funktion zur Ermittlung der eingestellten Sprache |
||||
# - DSM Sprache ermitteln (aus synoinfo.conf) |
||||
# - Browser Sprache ermitteln (aus ${HTTP_ACCEPT_LANGUAGE}) |
||||
# - wenn DSM Sprache = default, dann benutze Browser Sprache |
||||
# - Persönliche DSM Sprache ermitteln (aus usersettings) |
||||
# - falls Persönliche DSM Sprache = default, dann benutze weiterhin die zuvor |
||||
# ermittelte Sprache, ansonsten benutze die ermittelte Persönliche DSM Sprache |
||||
# - ist DSM Sprache und Persönliche DSM Sprache = "def" und Browser Sprache nicht gesetzt, dann benutze Standard Sprache (DEFLANG) |
||||
# Prioritäten: 1. Persönliche DSM Sprache =2. DSM Sprache =3. Browser Sprache =4. Standard Sprache |
||||
# |
||||
|
||||
# Übersetzungstabelle deklarieren |
||||
declare -A ISO2SYNO |
||||
ISO2SYNO=( ["de"]="ger" ["en"]="enu" ["zh"]="chs" ["cs"]="csy" ["jp"]="jpn" ["ko"]="krn" ["da"]="dan" ["fr"]="fre" ["it"]="ita" ["nl"]="nld" ["no"]="nor" ["pl"]="plk" ["ru"]="rus" ["sp"]="spn" ["sv"]="sve" ["hu"]="hun" ["tr"]="trk" ["pt"]="ptg" ) |
||||
|
||||
# DSM Sprache ermitteln |
||||
deflang="ger" |
||||
lang=$(cat /etc/synoinfo.conf | grep language | sed 's/language=//;s/\"//g' | egrep -o "^.{3}") |
||||
#lang_mail=$(cat /etc/synoinfo.conf | grep maillang | sed 's/maillang=//;s/\"//g' | egrep -o "^.{3}") |
||||
#if [ "$lang" == "def" ]; then |
||||
# lang="$lang_mail" |
||||
#fi |
||||
|
||||
if [[ "${lang}" == "def" ]] ; then |
||||
# Browsersprache ermitteln |
||||
if [ -n "${HTTP_ACCEPT_LANGUAGE}" ] ; then |
||||
bl=`echo ${HTTP_ACCEPT_LANGUAGE} | cut -d "," -f1` |
||||
bl=${bl:0:2} |
||||
lang=${ISO2SYNO[${bl}]} |
||||
else |
||||
lang=${deflang} |
||||
fi |
||||
fi |
||||
# Persönliche DSM Sprache ermitteln |
||||
usersettingsfile=/usr/syno/etc/preference/${login_user}/usersettings |
||||
if [ -f ${usersettingsfile} ] ; then |
||||
userlanguage=`jq -r ".Personal.lang" ${usersettingsfile}` |
||||
if [ -n "${userlanguage}" -a "${userlanguage}" != "def" -a "${userlanguage}" != "null" ] ; then |
||||
lang=${userlanguage} |
||||
fi |
||||
fi |
||||
|
||||
# Sprachdatei laden |
||||
if [ -f "lang/lang_${lang}.txt" ] && [[ "$lang" != "enu" ]]; then |
||||
source "lang/lang_${lang}.txt" |
||||
fi |
||||
} |