<?PHP
//........................

$table = THEMEMASTER;
$return = "themes.php";

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

if (!empty($_GET['id'])) {

        $SQL = "SELECT * from $table WHERE ID = '$_GET[id]'"; 
        $result = mySQL_query( $SQL ); 
        $row = mySQL_fetch_array( $result );

        if ($row[THEME] == 'default')
                $row[THEME] = defaultclone;

}

if (!empty($_GET[id]))
        $qt = update;
        
if (!empty($_GET['clone'])) {
        $qt = insert;
        $_GET[id] = "";
}

?>

<?PHP

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

function createRandomPassword() {

    $chars = "abcdefghijkmnopqrstuvwxyz023456789";
    srand((double)microtime()*1000000);
    $i = 0;
    $pass = '' ;

    while ($i <= 15) {
        $num = rand() % 33;
        $tmp = substr($chars, $num, 1);
        $pass = $pass . $tmp;
        $i++;
    }

    return $pass;

}

$password = createRandomPassword();

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

$SQLbeta = "SELECT * from THEMES WHERE THEMEID = '$row[THEMEID]'";
$resultbeta = @mySQL_query( $SQLbeta ); while( $rowbeta = @mySQL_fetch_array( $resultbeta ) ) {

        $sqlceti = "INSERT INTO `THEMES` SET
        THEMEID = '$password',
        CLASSCSS = '$rowbeta[CLASSCSS]',
        CLASSNAME = '$rowbeta[CLASSNAME]'";
        $queryceti  = mysql_query($sqlceti) or die("$sql_error" . mysql_error());
        
}
        
?>

<form name="form" method="post" action="index.php?page=query&return=<?php echo $_GET['return']; ?>">

<input type="hidden" name="controller" value="<?php echo $table; ?>~<?php echo $qt; ?>~<?php echo $return; ?>~<?php echo $_GET['id']; ?>">
<input type="hidden" name="THEMEID" value="<?php if (!empty($_GET['clone'])) echo $password; else echo $row[THEMEID]; ?>">
<h1><?PHP /* (LANGUAGE) */ $t = "Theme Creator"; $f = "header"; include "langinc.php"; /* (LANGUAGE) */ ?></h1>

<table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr> 

<td style="padding-right:10px;" width="50%" valign="top"> 

<h3><?PHP /* (LANGUAGE) */ $t = "Name of Theme"; $f = "themename"; include "langinc.php"; /* (LANGUAGE) */ ?></h3>

<input type="text" name="THEME" class="fieldbox" style="width: 100%; margin-bottom: 20px;" value="<?php echo $row[THEME]; ?>">

</td>

<td style="padding-left:10px;" width="50%" valign="top"> 

<h3><?PHP /* (LANGUAGE) */ $t = "Author"; $f = "author"; include "langinc.php"; /* (LANGUAGE) */ ?></h3>

<input type="text" name="AUTHOR" class="fieldbox" style="width: 100%;" value="<?php echo $row[AUTHOR]; ?>">

</td>

</tr>

</table>

<h3><?PHP /* (LANGUAGE) */ $t = "Description of Theme"; $f = "description"; include "langinc.php"; /* (LANGUAGE) */ ?></h3>

<input type="text" name="DESCRIPTION" class="fieldbox" style="width: 100%;" value="<?php echo $row[DESCRIPTION]; ?>">

<div style="float: right;">

<div style="float:right;"><input class="sparklybutton" type="submit" name="Save" value="<?PHP /* (LANGUAGE) */ $t = "Save"; $f = "save"; include "langinc.php"; /* (LANGUAGE) */ ?>" style="margin-top: 15px;"></div>

</div>

</form>
