<?
########## Confixx(R) 3.0 Professional ############
####### Copyright SWsoft, Inc. 2004-2005 ##########
#### http://www.sw-soft.com - info@sw-soft.com ####

include_once( "../include/class.SQLInteger.php" );
include_once( "../include/class.SQLString.php" );
include_once("auth.php");

if (istleer($pfad))	{
	$fehlertext = ltext("topwae2_error1");
	include("tools_pwschutz_aendern.php");
	exit();
			}

while (ereg("/$", $pfad))
	{
	 $pfad = substr($pfad, 0, -1);
	}

while (ereg("^/", $pfad))
	{
	 $pfad = substr($pfad, 1, (strlen($pfad) -1));
	}

$pfad = ereg_replace("/+", "/", $pfad);

if (substr($pfad, 0, 1) != "/") $pfad = "/".$pfad;
$dir = "/$PHP_AUTH_USER/html".$pfad;
exec($bindir."/lsdir.pl ".$dir, $devnull, $status);

if ($status != 0)
	{
	 $fehlertext = ltext("topwae2_error2", array($pfad));
	 include("tools_pwschutz_aendern.php");
	 exit();
	}


if ((ereg("[^A-Za-z0-9 ]", $bereich)) || (strlen($bereich) > 20))	{
	$fehlertext = ltext("topwae2_error3");
	include("tools_pwschutz_aendern.php");
	exit();
									}
if ($bereich == "") { // to prevent error500
    $bereich = "secure";
}

db_connect($db_host, $db_user, $db_pass);

$loUser = new SQLString( $PHP_AUTH_USER );
$loIdent = new SQLInteger( $ident );
$loPfad = new SQLString( $pfad );
## prüfen, ob verzeichnis schon mit pw geschützt
$id = safe_query2( "select * from pwschutz where kunde = ? and pfad = ? and ident != ?", 
									 $loUser, $loPfad, $loIdent );
if (db_num_rows($id) > 0)	{
	$fehlertext = ltext("topwae2_error4");
	db_close();
	include("tools_pwschutz_aendern.php");
	exit();
				}
## //
$id = safe_query2( "select * from pwschutz where kunde = ?  and ident = ? ", $loUser, $loIdent );
$werte = db_fetch_array($id);
$anbieter = $werte["anbieter"];
$pfad2 = $werte["pfad"];

$lc = time();
safe_query2( "update pwschutz set pfad = ? , bereich = ? , lastchange = ?  where kunde = ?  and ident = ? ",  
						$loPfad, new SQLString( $bereich ), new SQLInteger( $lc ), $loUser, $loIdent );

$id = safe_query2( "select * from htaccess where pfad = ?  and kunde = ? ", $loPfad , $loUser );
if (db_num_rows($id) < 1)	{
	safe_query2( "insert into htaccess (pfad, kunde) VALUES (  ? ,  ?  )", $loPfad, $loUser );
}

safe_query2( "update allgemein set htaccess=1" );

db_close();

$fehlertitel = ltext("topwae2_errortitle");
$fehlertext = ltext("topwae2_error5");
include("tools_pwschutz_aendern.php");
exit();
?>
