Subversion Repositories portal2

Rev

Rev 699 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php
/*  emg - Energy Monitoring & Graphing
*  Copyright (C) 2006-2012 Romain Lievin
*
*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 3 of the License, or
*  (at your option) any later version.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software Foundation,
*  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

?>

<?php
include_once('auth_check.php');

$error = new Error();

if(isset($_POST['form_theme_name']))
{
        if(strlen( $_POST['form_theme_name']) > 16 || strlen($_POST['form_theme_name']) < 2)
        {
                $error->push(_('Name must have [2-16] characters.'));
        }

        elseif( $_POST['form_token'] != $_SESSION['form_token'])
        {
                $error->push(_('Internal error: invalid form token.'));
        }

        else
        {
                $form_theme_name     = filter_var($_POST['form_theme_name'], FILTER_SANITIZE_STRING);
                $_SESSION['theme'] = $form_theme_name;

                $error->push(_('Theme changed successfully.'));
                $ok      = true;

                $id      = link_get_id_from_filename("form_theme.php");
                $refresh = $_SESSION['refresh_redirection'];
                echo "<meta http-equiv=\"refresh\" content=\"$refresh; URL=index.php?id_page=$id\">";
        }

        $form_token = $_SESSION['form_token'];
}
else
{
        $form_token = md5(uniqid('auth', true));
        $_SESSION['form_token'] = $form_token;
}
?>

<div id="page_theme_change">
        <h1>
                <?php echo _('Look &amp; Feel'); ?>
        </h1>

        <?php

        $id = link_get_id_from_filename("form_theme.php");
        echo "<form action=\"index.php?id_page=$id\" method=\"post\">";
        ?>
        <fieldset>
                <legend>
                        <?php echo _('Settings'); ?>
                </legend>


                <label for="form_theme_name">
                        <?php echo _('Theme'); ?>:
                </label>
                <?php
                $select = "\r\n";
                $select .= "<select name=\"form_theme_name\" id=\"form_theme_name\">";

                $iterator = new DirectoryIterator('themes');
                foreach($iterator as $fileinfo)
                {
                        if($fileinfo->isDir())
                        {
                                $filename = $fileinfo->getFilename();

                                if($filename == '.' || $filename == '..')
                                continue;

                                //echo $fileinfo->getFilename();
                                //echo " < br/>";

                                if($_SESSION['theme'] == $filename)
                                $select .= "<option value=\"$filename\" selected=\"selected\"> $filename </option>";
                                else
                                $select .= "<option value=\"$filename\"> $filename </option>";
                        }
                }

                $select .= "</select>\n";
                echo $select;
                ?>
                <br/>
               
                <hr/>
               
                <div class="buttons">
                        <input type="submit" name="form_theme_change" value=<?php echo _('Update'); ?> id="form_theme_change" alt="change" />
                        <input type="hidden" name="form_token" value="<?php echo $form_token; ?>" />
                </div>

        </fieldset>
        </form>

        <?php echo $error->display(); ?>

</div>