Prefered Method for User authetification on VHosts
| From: | Michelle Konzack | Date: | Wed, 01 Oct 2008 16:52:17 +0000 |
| Subject: | Prefered Method for User authetification on VHosts | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-281479@lists.php.net to get a copy of this message | ||
Hello,
I have at my hosting provider only 1 GByte of Diskspace and can install
VHosts as much as I want. The problem is, that I have "no access" to
the OS for OS-Level autentification.
Currently I have
${CUSTOMERPATH}/htdocs/index.php
which handel all VHosts and get ist config from directories like
${CUSTOMERPATH}/CONFIG_<vhost>.tamay-dogan.net/...
in which I currently use files like
<user>:<shadow_passwd>
and then I use:
----[ STDIN ]-----------------------------------------------------------
function login($user, $pass, $redirect) {
if ($user != '' and $pass != '') {
$SHADOW=exec("grep \"^$user:\" " . DIR_HOST . "/.shadow |cut -d:
-f2");
if (empty($SHADOW)) {
header("Content-Type: text/html");
die("<meta http-equiv=\"refresh\"
content=\"5;$redirect\">\n<font size=\"+2\"
color=\"red\"><b>Error</b></font><hr size=\"3\"
noshade=\"noshade\">The username \"$user\" does not exist.");
}
$SALT=exec("grep \"^$user:\" " . DIR_HOST . "/.shadow |cut -d: -f2 |cut
-d$ -f1-3");
$ENCRYPTED=crypt($pass, $SALT);
if ($SHADOW != $ENCRYPTED) {
header("Content-Type: text/html");
die("<meta http-equiv=\"refresh\"
content=\"5;$redirect\">\n<font size=\"+2\"
color=\"red\"><b>Error</b></font><hr size=\"3\"
noshade=\"noshade\">Wrong password for user \"$user\".");
}
$TIME_NOW=date("U");
$SESSID=exec("echo \"${user}${TIME_NOW}\" |md5sum |sed 's|
.*||'");
setcookie('TDSESSION', "$SESSID");
setcookie('USER', $user);
exec("echo '" . date("U") . " " . $user . "'
>" . DIR_SESSIONS . "/" . $SESSID);
}
if (empty($redirect)) {
$redirect="/";
}
header("Content-Type: text/html");
die("<meta http-equiv=\"refresh\" content=\"0;$redirect\">");
}
------------------------------------------------------------------------
which is working properly...
I like to know, whether this is good enough or is there a better
solution?
Thanks, Greetings and nice Day/Evening
Michelle Konzack
Systemadministrator
24V Electronic Engineer
Tamay Dogan Network
Debian GNU/Linux Consultant
--
Linux-User #280138 with the Linux Counter, http://counter.li.org/
##################### Debian GNU/Linux Consultant #####################
Michelle Konzack Apt. 917 ICQ #328449886
+49/177/9351947 50, rue de Soultz MSN LinuxMichi
+33/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com)