<?
########## 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" );

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");    // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-store, no-cache, must-revalidate");  // HTTP/1.1
header("Pragma: no-cache");                          // HTTP/1.0


error_reporting(7);

if (!isset($umgesetzt)) {
  $umgesetzt = true;
  if (is_array($_GET)) {
    foreach($_GET as $key => $val) {
      if (!is_array($val)) {
	if (get_magic_quotes_gpc()) $val = StripSlashes($val);
	//$val = AddSlashes(StripSlashes($val));
      }
      $$key = $val;
    }
  } elseif (is_array($HTTP_GET_VARS)) {
    foreach($HTTP_GET_VARS as $key => $val) {
      if (!is_array($val)) {
	if (get_magic_quotes_gpc()) $val = StripSlashes($val);
	//$val = AddSlashes(StripSlashes($val));
      }
      $$key = $val;
    }
  }

  if (is_array($_POST)) {
    foreach($_POST as $key => $val) {
      if (!is_array($val)) {
	if (get_magic_quotes_gpc()) $val = StripSlashes($val);
	//$val = AddSlashes(StripSlashes($val));
      }
      $$key = $val;
    }
  } elseif (is_array($HTTP_POST_VARS)) {
    foreach($HTTP_POST_VARS as $key => $val) {
      if (!is_array($val)) {
	if (get_magic_quotes_gpc()) $val = StripSlashes($val);
	//$val = AddSlashes(StripSlashes($val));
      }
      $$key = $val;
    }
  }
  
  if (is_array($_SERVER)) {
    foreach($_SERVER as $key => $val) {
      $$key = $val;
    }
  } elseif (is_array($HTTP_SERVER_VARS)) {
    foreach($HTTP_SERVER_VARS as $key => $val) {
      $$key = $val;
    }
  }

 if (is_array($_FILES)){
    foreach($_FILES as $key => $val) {
if($DEBUG){
  echo "key:  $key<br>\n";
  print_r($val);
  echo "\n";
}		
      if (is_array($val)) {
	$$key = $val['tmp_name'];
	$fkey=$key.'_name';
	$$fkey = $val['name'];
	$fkey=$key.'_size';
	$$fkey = $val['size'];
	$fkey=$key.'_type';
	$$fkey = $val['type'];
      }
    }
  }elseif(is_array($HTTP_POST_FILES)){
    foreach($HTTP_POST_FILES as $key => $val) {
      if (!is_array($val)) {
	$$key = $val['tmp_name'];
	$fkey=$key.'_name';
	$$fkey = $val['name'];
	$fkey=$key.'_size';
	$$fkey = $val['size'];
	$fkey=$key.'_type';
	$$fkey = $val['type'];
      }
    }
  }

  unset($key, $val);
}

$PHP_AUTH_USER = $PHP_AUTH_PW = '';

include("../settings.inc.php");
include("../functions.inc.php");
include('../sessions.inc.php');

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

sessao_start();

if(preg_match('/^\/poplogin\/([^\/]+)\/.*$/',$_SERVER['REQUEST_URI'], $ma))
{
	//$url_user = $ma[1];	
	if(isSUserLogged($ma[1]))
	{
		$PHP_AUTH_USER = strtolower(trim($ma[1]));
		$PHP_AUTH_PW = $_SESSION['_users'][$PHP_AUTH_USER]['password'];
		if(!checkPopLogin($PHP_AUTH_USER, $PHP_AUTH_PW))
		{
			$PHP_AUTH_USER = $PHP_AUTH_PW = '';
		}
	}
}


if(!$PHP_AUTH_USER || !$PHP_AUTH_PW)
{
	$_cat = 'pop3';	// this makes a signal of where from the authorisation request came
	db_close;
	include('../loginform.php');
	exit();
}

$loUser = new SQLString($PHP_AUTH_USER);
$uid = safe_query( "SELECT language, kunde, anbieter FROM pop3 WHERE account=?", $loUser);
$werte = db_fetch_array($uid);
$kunde = $werte['kunde'];
$anbieter = $werte["anbieter"];
$shortlang = $werte["language"]?$werte["language"]:"en";
$miscf = $shortlang."/misc.inc.php";
$langf = $shortlang."/user.inc.php";
include("../languages/$miscf");
include("../languages/$langf");

$strSkinName="../user/skins/default";
$uid = safe_query2( "SELECT anbieter FROM pop3 WHERE account = ? ", $loUser );
$werte = db_fetch_array($uid);
$anbieter = $werte["anbieter"];

$strSkinName="/skins/skin_1";
$confixx_interface_version = 'xp30';
$qid = safe_query2( "SELECT custom_skins.path AS path, custom_skins.version AS version ".
										" FROM skins INNER JOIN custom_skins ON (skins.skin_id = custom_skins.id)".
										" WHERE skins.cuser=?" , new SQLString( $anbieter ) );
if(db_num_rows($qid))
{
	$werte = db_fetch_array($qid);
	$confixx_interface_version = $werte['version'];
	$strSkinName = $werte['path'];
}

## //
if($confixx_interface_version == 'classic20')
{
	$strSkinName = '/user/' . $strSkinName;
}
else
{
	include_once('gui/module.GuiXP.php');
	$gui = new tGuiXP($strSkinName); // trailing slash !!!
}

db_close();
?>
