AlternC/tools/alternc_get_path

39 lines
877 B
Plaintext
Raw Normal View History

2013-02-13 10:37:15 +00:00
#! /bin/bash
2013-02-18 17:45:17 +00:00
source /usr/lib/alternc/functions.sh
path="$1"
2013-02-13 10:37:15 +00:00
if [ -z "$path" ] ; then
echo "Give a full-path directory to this script, it will tell"
echo "you if you can access it with a website"
echo ""
echo "Missing parameters"
echo "Usage: $0 <directory>"
2013-02-18 17:45:17 +00:00
echo "Example: $0 $ALTERNC_HTML/admin/mydir/"
2013-02-13 10:37:15 +00:00
exit 0
fi
2013-02-18 17:45:17 +00:00
account=`echo "$path" | sed "s#$ALTERNC_HTML/./##" | cut -d '/' -f 1`
relpath=`echo "$path" | sed "s#$ALTERNC_HTML/./[^/]*##"`
2013-02-13 10:37:15 +00:00
request="SELECT
m.login AS user,
CONCAT('http://', s.sub, if(s.sub='','','.'), s.domaine, s.valeur) AS fqdn
FROM
sub_domaines s,
membres m,
domaines_type dt
WHERE
m.login='$account'
AND m.uid = s.compte
AND s.type = dt.name
AND dt.target = 'DIRECTORY'
AND '$relpath' LIKE CONCAT( if(s.valeur='','/',s.valeur) ,'%')
ORDER BY sub ASC
;
"
mysql --defaults-file=/etc/alternc/my.cnf -B -e "$request"