<?php

include("../includes/site_config.php");
include('../session_handler.inc');
include('../message.php');
include('error_admin.php');
error_reporting(0);

$Sess_UserType=$_SESSION['Sess_UserType'];
if ($Sess_UserType != "A") {exit;}

if(isset($_REQUEST['skin'])){
restrict_demo();
$skin=form_get('skin');


if (isset($_FILES['logo'])) {
if ($_FILES['logo']['type'] == "image/gif" || $_FILES['logo']['type'] == "image/GIF") {
            if ( $_FILES['logo']['type'] == "image/gif"  || $_FILES['logo']['type'] == "image/GIF") { $extension=".gif"; }
    # check whether immediate authorisation
    if ($_FILES['logo']['name'] != "") {
       
            $tempusername="logo";
			$filename="$tempusername"."$extension";
          	$targetfile="templates/".$skin."/images/"."$filename";
           	//createThumbs(115, 115, $_FILES['imgFile']['logo'], 'jpg', "../$targetfile");
			chmod("../$targetfile", 0777);
			$copy = copy($_FILES['logo']['tmp_name'],"../$targetfile");
			if(!$copy){error_admin(sprintf(PRGPICADMIN_ERROR_COPY,$skin),CHANGE_PERMISSION_ERROR);}
			
        
           
        	
        } else {
            error_admin(PRGPICADMIN_ERROR3,GENERAL_USER_ERROR);
        }
    }
}










//$que=mysql_query("UPDATE options set Value='$skin' where Name='skin'") or die(mysql_error());

	}


?>


<link rel="stylesheet" href="../lightbox2/lightbox.css" type="text/css" media="screen" />
<script type="text/javascript" src="../lightbox2/lightbox.js"></script>


<!--<script type="text/javascript" src="../lightbox/js/prototype.js"></script>
<!--<script type="text/javascript" src="../lightbox/js/scriptaculous.js?load=effects"></script>
<script type="text/javascript" src="../lightbox/js/lightbox.js"></script>
<link rel="stylesheet" href="../lightbox/css/lightbox.css" type="text/css" media="screen" />-->

<?
$area = 'member';

$manager = &OptionManager::GetInstance();
$aGroups = $manager->GetGroupList();


	function display_option($option, $DEMO, $CONST_LINK_ROOT) {
    $res = "";
	
    if($option->type=='skin'){
		
      
	   $i=0;
	   //$res.= "<tr valign='top'>";
		foreach ($option->list as $value => $label){
		$selected = ($value == $option->value) ? "Current" : "Activate";
					
			if($DEMO==false){
				$link="<a href=\"admin_templates.php?skin=$label\">$selected</a>"; 
				}
				
		$res.= "
		 <form action='".$_SERVER['PHP_SELF']."' name=\"coupForm\" method=\"post\" enctype=\"multipart/form-data\">
		<tr><td align='center' class='admin-head'>$label&nbsp;</td>
		<td><input type='file' name='logo'><input type='submit' value='Upload' name='submit'>
		<input type='hidden' name='skin' value='$label'>
		</td>
		<td>
			<a href='$CONST_LINK_ROOT/templates/$label/images/logo.gif' rel='lightbox' title='$label'>
			<img src=\"$CONST_LINK_ROOT/templates/$label/images/logo.gif\" width='150' height='53'></a>
		</td>
		<tr><td colspan='3'></td></tr>
		<tr>
		</form>";
		
          
   		$i++; }
		   
    }
	
    return $res;
}
	
?>


<?php include("include/header.php"); ?><div class="mainwidth">

<div class="admin-page-header"><div class="admin-page-heading">&nbsp;&nbsp;<?=ADMIN_LOGO?></div></div>
<div class="clear"></div>
<div class="admin-page">
<table width="100%" align="<?php print("$CONST_TABLE_ALIGN"); ?>" border="0" cellspacing="<?php print("$CONST_TABLE_CELLSPACING"); ?>" cellpadding="<?php print("$CONST_TABLE_CELLPADDING"); ?>"><!--DWLayoutTable-->

<tr>

<?  
$group = 'general'; 

 $aOptions = ($group !== null) ? $manager->GetListByGroup($group) : array();
 $i=0;
foreach ($aOptions as $option){

?>
        

            
			<?=display_option($option, $DEMO, $CONST_LINK_ROOT)?>

             
		
           <?  }?>

  </tr>
 
</table>
</div><div class="admin-page-bottom"></div></div>


<?php include("include/footer.php"); ?>
