<?PHP

$table = "THEMEMASTER";
include "delete.php";
$editpage = "addthemes";
//........................

if ($_GET[settheme] == 1) {
        
        $table = "$prefix" . "SETTINGS";
        $sql    = "UPDATE $table SET
        THEME   = '$_GET[theme]' WHERE ID = '1'";
        $query  = @mysql_query($sql);

        $SQLxxx = "SELECT * from $table"; $resultxxx = @mySQL_query( $SQLxxx ); $rowxxx = @mySQL_fetch_array( $resultxxx );

}

?> 

<?PHP

//........................

$SQLbeta = "SELECT * from THEMES";
$resultbeta = @mySQL_query( $SQLbeta ); 
while( $rowbeta = @mySQL_fetch_array( $resultbeta ) ) {

	$SQLceti = "SELECT * from `THEMEMASTER` WHERE THEMEID = '$rowbeta[THEMEID]'"; $resultceti = @mySQL_query( $SQLceti ); $rowceti = @mySQL_fetch_array( $resultceti );

	if (!$rowceti)
		$sqldelta = "DELETE FROM THEMES WHERE THEMEID = '$rowbeta[THEMEID]'"; mysql_query("$sqldelta");     
}

//........................

?>

<?php if ($_GET[themereset] == 1) { ?>

<div class="primebox" style="width: 100%;">

<h1><?PHP /* (LANGUAGE) */ $t = "Reset Successful"; $f = "resetheader"; include "langinc.php"; /* (LANGUAGE) */ ?></h1>

<?PHP /* (LANGUAGE) */ $t = "The default theme has been reset."; $f = "resetmessage"; include "langinc.php"; /* (LANGUAGE) */ ?>

</div>

<?PHP } ?>

<table width="100%" border="0" cellspacing="0" cellpadding="0" style="margin-bottom: 10px;">

<tr> 

<td width="100%"> 

<h1><?PHP /* (LANGUAGE) */ $t = "Themes"; $f = "header"; include "langinc.php"; /* (LANGUAGE) */ ?></h1>

</td>

<td style="padding-right: 10px;" nowrap><a href="../index.php?designmode=on" target="_blank" title="<?PHP /* (LANGUAGE) */ $t = "Edit the Current Theme"; $f = "edittip"; include "langinc.php"; /* (LANGUAGE) */ ?>"><img style="float: right;" src="http://<?php echo $_SERVER[HTTP_HOST]; ?>/webifycore/images/design.png" border="0"></a> </td>

<td nowrap><a href="index.php?page=themehq" title="<?PHP /* (LANGUAGE) */ $t = "Download More Themes from our Online Theme Library"; $f = "downloadtip"; include "langinc.php"; /* (LANGUAGE) */ ?>"><img style="float: right;" src="http://<?php echo $_SERVER[HTTP_HOST]; ?>/webifycore/images/library.png" width="64" height="64" border="0"></a> </td>

</table>

<form name="form" method="post" action="index.php?page=themes&delete=1">

<?PHP
$SQL = "SELECT * from THEMEMASTER ORDER BY ID DESC";
$result = @mySQL_query( $SQL ); while( $row = @mySQL_fetch_array( $result ) ) {
?>

<table style="margin-bottom: 15px;" width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td width="100%" class="primebox"> 

<input title="<?PHP /* (LANGUAGE) */ $t = "Check to Delete"; $f = "checktip"; include "langinc.php"; /* (LANGUAGE) */ ?>" style="float: right;" type="checkbox" name="<?php echo $row[ID]; ?>" value="<?php echo $row[ID]; ?>" <?php if ($row[THEME] == 'default') { ?> disabled <?PHP } ?>>

<?PHP
if ($row[THEMEID] != '1')
        $css = "link";
?>

<span class="<?php echo $css; ?>large">

<?php 
$url = "index.php?page=$editpage&id=$row[ID]";
$link = "<a href=\"$url\">$row[THEME]</a>";

if ($row[THEMEID] == '1')
        $link = "$row[THEME]";
?>

<?PHP echo $link; ?>

</span> 

<hr>

<?PHP if ($rowxxx[THEME] == $row[THEMEID]) $active = active; ?>

<a href="index.php?page=themes&theme=<?php echo $row[THEMEID]; ?>&settheme=1" title="<?PHP /* (LANGUAGE) */ $t = "Set as Active Theme"; $f = "setactive"; include "langinc.php"; /* (LANGUAGE) */ ?>"><img style="margin-top:5px;  float: right;" class="<?php echo $active; ?>thumb" src="http://<?php echo $_SERVER[HTTP_HOST]; ?>/webifycore/images/check.png" width="32" height="32" border="0"></a>

<a href="index.php?page=<?php echo $editpage; ?>&id=<?php echo $row[ID]; ?>&clone=1" title="<?PHP /* (LANGUAGE) */ $t = "Create New Theme"; $f = "clonetheme"; include "langinc.php"; /* (LANGUAGE) */ ?>"><img style="margin-top:5px; margin-right:5px; float: right;" class="thumb" src="http://<?php echo $_SERVER[HTTP_HOST]; ?>/webifycore/images/clone.png" width="32" height="32" border="0"></a>

<a href="index.php?page=edittheme&id=<?php echo $row[ID]; ?>&theme=<?php echo $row[THEMEID]; ?>" title="<?PHP /* (LANGUAGE) */ $t = "Edit Theme CSS"; $f = "editcss"; include "langinc.php"; /* (LANGUAGE) */ ?>"><img style="margin-top:5px; margin-right:5px; float: right;" class="thumb" src="http://<?php echo $_SERVER[HTTP_HOST]; ?>/webifycore/images/design.png" width="32" height="32" border="0"></a>

<?PHP if ($row[THEMEID] != '1') { ?>

<a href="index.php?page=themeexport&theme=<?php echo $row[THEMEID]; ?>" title="<?PHP /* (LANGUAGE) */ $t = "Share this Theme with the Webify Community"; $f = "sharetheme"; include "langinc.php"; /* (LANGUAGE) */ ?>"><img style="margin-top:5px; margin-right:5px; float: right;" class="thumb" src="http://<?php echo $_SERVER[HTTP_HOST]; ?>/webifycore/images/export.png" width="32" height="32" border="0"></a>

<?PHP } ?>

<?PHP if ($row[THEMEID] == '1') { ?>

<a href="index.php?page=themes&themereset=1" title="<?PHP /* (LANGUAGE) */ $t = "Reset to Default. Warning, this will reset any changes that you have made to the default theme!"; $f = "resettheme"; include "langinc.php"; /* (LANGUAGE) */ ?>"><img style="margin-top:5px; margin-right:5px; float: right;" class="thumb" src="http://<?php echo $_SERVER[HTTP_HOST]; ?>/webifycore/images/reset.png" width="32" height="32" border="0"></a>

<?PHP } ?>

<?PHP $active = ""; ?>

<?php echo $row[DESCRIPTION]; ?>

</td>

</table>

<?php } ?>

<?PHP include "deletebar.php"; ?>

</form>
