<?php

(!defined('IN_PowerBB')) ? die() : '';

define('STOP_STYLE',true);

include('common.php');

define('CLASS_NAME','PowerBBChangeStyleMOD');

class PowerBBChangeStyleMOD
{
	function run()
	{
		global $PowerBB;

		$PowerBB->_GET['id'] = $PowerBB->functions->CleanVariable($PowerBB->_GET['id'],'intval');

		if (empty($PowerBB->_GET['id']))
		{
			$PowerBB->functions->error($PowerBB->_CONF['template']['lang']['path_not_true']);
		}

		if ($PowerBB->_GET['change'])
		{
			$StyleArr 				= 	array();
			$StyleArr['field']		=	array();

			$StyleArr['field']['style'] = $PowerBB->_GET['id'];

			if ($PowerBB->_CONF['member_permission'])
			{
				$StyleArr['where'] = array('id',$PowerBB->_CONF['member_row']['id']);

				$change = $PowerBB->member->UpdateMember($StyleArr);
			}
			else
			{
				$Style_id = $PowerBB->_GET['id'];
                ob_start();
                setcookie("PowerBB_style", $Style_id, time()+3600);
                ob_end_flush();
		                if (strstr($PowerBB->_SERVER['HTTP_REFERER'],$PowerBB->functions->GetForumAdress()))
						{
							$PowerBB->functions->redirect2($PowerBB->_SERVER['HTTP_REFERER']);
						}
						else
						{
							$PowerBB->functions->redirect2('index.php');
						}



			}

			if ($change)
			{
                    $redirect1 = $PowerBB->functions->redirect2('index.php');
                    $redirect2 = $PowerBB->functions->redirect2($PowerBB->_SERVER['HTTP_REFERER']);

		                if (strstr($PowerBB->_SERVER['HTTP_REFERER'],$PowerBB->functions->GetForumAdress()))
						{
							$PowerBB->functions->redirect2($PowerBB->_SERVER['HTTP_REFERER']);
						}
						else
						{
							$PowerBB->functions->redirect2('index.php');
						}
			}
		}
		else
		{
			$PowerBB->functions->error($PowerBB->_CONF['template']['lang']['path_not_true']);
		}
	}

}

?>
