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

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

if (!checkUserLogin($PHP_AUTH_USER, $altpw))
	{
	 $fehlertext = ltext("alpw2_error1");
	 include("allgemein_pwaendern.php");
	 exit();
	}

if ($neupw1 != $neupw2)
	{
	 $fehlertext = ltext("alpw2_error3");
	 include("allgemein_pwaendern.php");
	 exit();
	}

if (!valid_pw($neupw1))
	{
	 $fehlertext = ltext("alpw2_error4");
	 include("allgemein_pwaendern.php");
	 exit();
	}

$neupw = crypt_pw($neupw1);
db_connect($db_host, $db_user, $db_pass);

$id = safe_query( "select statistik from kunden where kunde = ? ", TRUE, new SQLString( $PHP_AUTH_USER ) );
$werte = db_fetch_array($id);
$statistik = $werte["statistik"];

if ($statistikpwaendern && $statistik == 1){
	safe_query( "update kunden set longpw = ? , pw=1, statistiklongpw = ?  where kunde = ? ", TRUE, new SQLString( $neupw ), new SQLString( $neupw ), new SQLString( $PHP_AUTH_USER ) );
	safe_query( "update allgemein set webalizerpw='1', newpwd='1'", TRUE );
}else{
	safe_query( "update kunden set longpw = ? , pw=1 where kunde = ? ", TRUE, new SQLString( $neupw ), new SQLString( $PHP_AUTH_USER ) );
	safe_query( "update allgemein set newpwd='1'", TRUE );
}

$fehlertitel = ltext("alpw2_error5");
$fehlertext = ltext("alpw2_error6");
db_close();
header("Location: ./allgemein_pwaendern.php?fehlertext=".urlencode($fehlertext)."&fehlertitel=".urlencode($fehlertitel));
?>
