138 lines
2.6 KiB
Plaintext
138 lines
2.6 KiB
Plaintext
#
|
|
# Important/useful functions for the CGI-scripts
|
|
#
|
|
#
|
|
# Copyright 2000 Wilmer van der Gaast (lintux@lintux.cx)
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program; if not, write to the Free Software
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
function var()
|
|
{
|
|
eval echo \$$*;
|
|
}
|
|
|
|
function getconfig_clean()
|
|
{
|
|
cat $MARS_CONFIG | grep "^[ ]*$1[^0-9]";
|
|
}
|
|
|
|
function getconfig()
|
|
{
|
|
getconfig_clean "$1" | sed -e "s/[ ]\+/ /g" | cut -d\# -f1 | sed -e "s/^[ ]\+//";
|
|
}
|
|
|
|
function getentry()
|
|
{
|
|
declare -i t; t=0
|
|
while [ "$t" != "$1" ]; do
|
|
t=$t+1
|
|
if [ "$t" = "$1" ]; then
|
|
sed q;
|
|
fi
|
|
read TMPCRAP;
|
|
done;
|
|
}
|
|
|
|
function convert()
|
|
{
|
|
echo $* | sed "s/ /\ \+/g"
|
|
}
|
|
|
|
function anticonfig()
|
|
{
|
|
grep -v "^[ ]*$1[^0-9]";
|
|
}
|
|
|
|
function getlangs()
|
|
{
|
|
echo `echo $ACCEPT_LANGUAGE | sed -e "s/,//g"`
|
|
}
|
|
|
|
function convertfilename()
|
|
{
|
|
echo $* | sed "s/\%2F/\//g" ;
|
|
}
|
|
|
|
function digit()
|
|
{
|
|
if [ -z $1 ]; then
|
|
echo 0;
|
|
elif [ "$1" = on ]; then
|
|
echo 1;
|
|
fi;
|
|
}
|
|
|
|
function checkrefer()
|
|
{
|
|
if [ -z "$REFERER" ]; then
|
|
cat<<EOF
|
|
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE>Unsupported browser error</TITLE>
|
|
</HEAD>
|
|
<BODY>
|
|
The browser you are using does not send the <I>Referer:</I> tag needed by
|
|
SMArT, or you're working from behind a proxy server that blocks the
|
|
<I>Referer:</I> tag. It might be possible to tell your browser not to use
|
|
a proxy server for this URL, or you'll have to switch to a different browser,
|
|
like Netscape 4.x, and you can even use the text mode Lynx.
|
|
</BODY>
|
|
</HTML>
|
|
EOF
|
|
exit;
|
|
fi;
|
|
}
|
|
|
|
function checkbind()
|
|
{
|
|
if ! [ -x "`which nwbols`" ]; then
|
|
cat << EOF
|
|
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE>Bindery utilities error</TITLE>
|
|
</HEAD>
|
|
<BODY BGCOLOR=#C0C0C0>
|
|
Could not find the nwb[op]* utilities that are necessary to access the
|
|
bindery! These programs can be found in the <TT>ncpfs</TT> package on
|
|
(Red Hat) Linux systems, but as far as I know, they don't exist for
|
|
FreeBSD.
|
|
</BODY>
|
|
</HTML>
|
|
EOF
|
|
exit 1;
|
|
fi;
|
|
}
|
|
|
|
function checkparams()
|
|
{
|
|
if [ -z "$*" ]; then
|
|
cat << EOF
|
|
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE>Missing parameter(s)</TITLE>
|
|
</HEAD>
|
|
<BODY>
|
|
Missing parameter(s)! Please don't call this cgi-bin directly.
|
|
</BODY>
|
|
</HTML>
|
|
EOF
|
|
exit;
|
|
fi;
|
|
}
|