<?php

defined('INDEX_CHECK') or die ('<div style="text-align: center">Action non-autorisée !</div>');

if($user[1] == 9)
{
    function index()
    {
?>
        <div style="overflow: hidden;margin: 10px 12px;">
		            <a style="float: left;margin-left: 10px;" href="index.php?file=Admin&amp;page=theme&amp;gestion=pref">
                       <img src="themes/Storka/images/admin/pref.png" alt="preferences">
                    </a>
                    <a style="float: left;margin-left: 10px;" href="index.php?file=Admin&amp;page=theme&amp;gestion=social">
                        <img src="themes/Storka/images/admin/social.png" alt="social">
                    </a>
        </div>
<?php
    }
	
    function social()
    {
        if($_GET['action'] == 'save')
		{
            $account = '<?php $facebook = \'' . $_POST['facebook'] . '\'; $twitter = \'' . $_POST['twitter'] . '\'; $rss = \'' . $_POST['rss'] . '\'; $google = \'' . $_POST['google'] . '\';';
	
            $files = fopen('themes/Storka/admin/social.php', 'w+');
            fwrite($files, $account . ' ?>');
            fclose($files);

	        echo '<div style="margin: 12px"><div class="notification success png_bg"><div>Configuration enregistrée avec succès !</div></div></div>';
	        redirect('index.php?file=Admin&page=theme', 2);
        }
        else
        {	
            include('themes/Storka/admin/social.php');	
?> 
            <div style="margin: 5px">
			<div class="notification information png_bg">
	            <a onclick="del();return false" href="#" class="close"><img src="modules/Admin/images/icons/cross_grey_small.png" title="Close this notification" alt="close"></a>
                <div>
	               Laissez le champ vide pour désactiver l'icône.
	            </div>
			</div>
        </div>		
            <div style="margin: 12px">		
                <form method="post" action="index.php?file=Admin&amp;page=theme&amp;gestion=social&amp;action=save">
                    <table style="margin: 0 auto" border="0" cellspacing="1" cellpadding="2">
						<tr>
                            <td style="width: 15%;">Flux rss</td>
                            <td><input size="50" type="text" name="rss" size="50" value="<?php echo $rss; ?>" /></td>
                        </tr>
                        <tr>
                            <td>Facebook</td>
                            <td><input size="50" type="text" name="facebook" size="50" value="<?php echo $facebook; ?>" /></td>
                        </tr>
                        <tr>
                            <td>Twitter</td>
                            <td><input size="50" type="text" name="twitter" size="50" value="<?php echo $twitter; ?>" /></td>
                        </tr>
	                   <tr>
                            <td>Google plus</td>
                            <td><input size="50" type="text" name="google" size="50" value="<?php echo $google; ?>" /></td>
                        </tr>
                    </table>
                    <br />
				    <p><input class="button" type="submit" value="Envoyer" /></p>
                </form>
			</div>
            <div style="text-align: center;">[ <a href="index.php?file=Admin&page=theme"><b>Retour</b></a> ]</div><br />
<?php
        }
    }
    function pref()
    {
        if($_GET['action'] == 'save')
		{
            $message = '<?php $topmess = \'' . $_POST['topmess'] . '\'; $btitre = \'' . $_POST['btitre'] . '\'; $bmess = \'' . $_POST['bmess'] . '\';';
	
            $files = fopen('themes/Storka/admin/preferences.php', 'w+');
            fwrite($files, $message . ' ?>');
            fclose($files);

	        echo '<div style="margin: 12px"><div class="notification success png_bg"><div>Configuration enregistrée avec succès !</div></div></div>';
	        redirect('index.php?file=Admin&page=theme', 2);
        }
        else
        {	
            include('themes/Storka/admin/preferences.php');	
?> 	
            <div style="margin: 12px">		
                <form method="post" action="index.php?file=Admin&amp;page=theme&amp;gestion=pref&amp;action=save">
                    <table style="margin: 0 auto" border="0" cellspacing="1" cellpadding="2">
						<tr>
                            <td style="width: 15%;">Message d'accueil</td>
                            <td><input size="50" type="text" name="topmess" size="50" value="<?php echo $topmess; ?>" /></td>
                        </tr>
                        <tr><td></td></tr>
                        <tr>
                            <td>Titre bas de page</td>
                            <td><input size="50" type="text" name="btitre" size="50" value="<?php echo $btitre; ?>" /></td>
                        </tr>
                        <tr>
                            <td style="vertical-align: top;">Message bas de page</td>
                            <td><textarea class="noeditor" id="bmess" name="bmess" rows="10" cols="50"><?php echo $bmess; ?></textarea></td>
                        </tr>
                    </table>
                    <br />
				    <p><input class="button" type="submit" value="Envoyer" /></p>
                </form>
			</div>
            <div style="text-align: center;">[ <a href="index.php?file=Admin&page=theme"><b>Retour</b></a> ]</div><br />	



<?php
        }
    }			

    switch($_REQUEST['gestion'])
    {
        case 'index':
	    index();
	    break;
	
        case 'social':
	    social();
	    break;
	
        case 'pref':
	    pref();
	    break;

        default:
	    index();
	    break;
    }
}
?>
