<?php
/**
 * $Source: /home/cvs/nukescripts/modules/Your_Account/public/savetheme.php,v $
 * $Revision: 3.3.1-1 $
 * $Author: cyril $
 * $Date: 2006/08/01 12:47:36 $
 * Fix 'changement de theme' ( Bug 108 ) frenatus & killermanlille
 */
/********************************************************/
/* NSN Your Account                                     */
/* By: NukeScripts Network (webmaster@nukescripts.net)  */
/* http://www.nukescripts.fr                            */
/* Original Script www.nukescripst.net                  */
/* Copyright  2000-2005 by NukeScripts Network         */
/* ==================================================== */
/* Based from:                                          */
/* PHP-NUKE: Web Portal System                          */
/********************************************************/

if (!defined('IN_YA')) { die("You can't access this file directly."); }
if (!defined('MAXIMUS')) {
header("Location: index.php");
  die();
}

    if (defined('USER_ALLOW')) {
  if ($ya_config['allowusertheme']==1) {
    cookiedecode($user);
    $check  = $cookie[1];
    $check2 = $cookie[2];
    $theme_error = "";
    $user_id  = $GLOBALS['db']->XMFnum($user_id);
    $theme_id = $GLOBALS['db']->XMFnum($theme_id);
    $theme    = htmlentities(addslashes($theme)) ;
    $result = $db->sql_query("SELECT `user_id`, `user_password` FROM `".TABLE_USERS."` WHERE `username`='$check'");
    $row     = $db->sql_fetchrow($result);
    $user_id = $db->XMFnum($row['user_id']);
    $ccpass  = stripslashes($row['user_password']);
    if ( $check2 == $ccpass ) {
        $db->sql_query("UPDATE `".TABLE_USERS."` SET `user_style`='$theme_id' WHERE `user_id`='$user_id'");
        $db->sql_query("UPDATE ".TABLE_USERS." SET `theme`='$theme' WHERE `user_id`='$user_id'");
        getusrinfo($user);
        yacookie($userinfo['user_id'],$userinfo['username'],$userinfo['user_password'],$userinfo['storynum'],$userinfo['umode'],$userinfo['uorder'],$userinfo['thold'],$userinfo['noscore'],$userinfo['ublockon'],$userinfo['theme'],$userinfo['commentmax']);
        redirect_url("modules.php?name=$module_name&theme=$theme");
    }
  } else { disabled(); }
} else {
	notuser();
}