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

include_once("auth.php");
include_once( "../include/module.Database.php" );

$languages = get_langs();

#if (!in_array($language,$languages)) #php4
$in_array = 0;
for ($i=0;$i<count($languages["short"]);$i++)
	{
	 if ($languages["short"][$i] == $language) { $in_array = 1; }
	}

if (!$in_array)
	{
	 $fehlertext = ltext("alsp2_error1");
	 include("allgemein_sprache.php");
	 exit();
	 db_close();
	}

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

$loUser = new SQLString($PHP_AUTH_USER);
safe_query2( "UPDATE anbieter SET language = ? WHERE anbieter = ?", new SQLString($language), $loUser);

$skin = $skin * 1;
$id = safe_query2( "SELECT name, owner_type, version FROM custom_skins WHERE id = $skin AND ".
									 " ( owner_type = 'preinstalled' OR (anbieter=? and owner_type='reseller') ) ", $loUser);
if(db_num_rows($id))
{
	$res = db_fetch_array($id);
	/* -------------------- maybe, update name of skin -------------------- */
	$id = safe_query2( "SELECT MIN(id) AS minid FROM custom_skins WHERE anbieter = ?", $loUser );
	if ( $werte = db_fetch_array($id) ){
		$minid = $werte["minid"];
		if($minid) {
			$id = db_query( "SELECT show_name FROM custom_skins WHERE id = $minid" );
			$werte = db_fetch_array($id);
			if ( ltext("sk_default_skin") == $werte["show_name"] ) {
				include( "../languages/$language/misc.inc.php" );
				include( "../languages/$language/reseller.inc.php" );
				db_query( "UPDATE custom_skins SET show_name = " . db_full_quote(ltext("sk_default_skin")) .
						" WHERE id = $minid" );
			}
		}
	}
	/* -------------------- end maybe, update name of skin -------------------- */
	safe_query2( "UPDATE skins SET skin_id=$skin WHERE cuser=?", $loUser );
?>
<script>

<?
	$id = db_query("SELECT version FROM custom_skins WHERE id=$skin");
	$res = db_fetch_array($id);

	if($confixx_interface_version != $res['version'] || $res['version'] == 'classic20'):
?>
top.location.href = 'index.php';
<? else: ?>
top.leftFrame.location.href = 'ver_xp30_frame_left_nav_tree.php?op_block=general&op_item=design_language';
<? endif; ?>

</script>
<?
}


db_close();

include("allgemein_sprache.php");
?>
