Jump to content

PHP Theme System


plasmagames

Recommended Posts

change

                <?php
                //Use a switch statement to go through the URLS.
                switch ($nav) {
                    case "login":
                        include ('login.php');
                        break;

                    case "logout":
                        include ('logout.php');
                        break;

                    case "editprofile":
                        include ('editprofile.php');
                        break;

                    case "memberlist":
                        include ('memberlist.php');
                        break;

                    case "register":
                        include ('register.php');
                        break;

                    case "viewterms";
                        include ('terms.php');
                        break;

                    case "forgot";
                        include ('reset_pw.php');
                        break;

                    case "profile";
                        include ('profile.php');
                        break;
                  
                    case "admin";
                        include ('admin/index.php');
                        break;
                  
               case "theme";
                        include ('admin/theme.php');
                        break;
                  
               case "news";
                        include ('admin/news.php');
                        break;
                  
               case "general";
                        include ('admin/general.php');
                        break;
                  
               case "download";
                        include ('download.php');
                        break;
                  
               case "game";
                        include ('game.php');
                        break;
                  
               case "tutorial";
                        include ('tutorial.php');
                        break;
                  
               case "contact";
                        include ('contact.php');
                        break;

                    default:
                        include ('default.php');
                        break;


                }

                ?>

to

                <?php

                $pages = array( 'login'       => 'login.php',
                                'logout'      => 'logout.php',
                                'editprofile' => 'editprofile.php',
                                'memberlist'  => 'memberlist.php',
                                'register'    => 'register.php',
                                'viewterms'   => 'terms.php',
                                'forgot'      => 'reset_pw.php',
                                'profile'     => 'profile.php',
                                'admin'       => 'admin/index.php',
                                'theme'       => 'admin/theme.php',
                                'news'        => 'admin/news.php',
                                'general'     => 'admin/general.php',
                                'download'    => 'download.php',
                                'game'        => 'game.php',
                                'tutorial'    => 'tutorial.php',
                                'contact'     => 'contact.php');

                if(isset($pages[$nav]))
                {
                    include './'.$pages[$nav];
                }
                else
                    include './default.php';

                ?>

Link to comment
Share on other sites

ok i just changed the theme and it come with an error but the theme still changes

 

error

Warning: rename(/home/a5880517/public_html/isus/theme/psg,/home/a5880517/public_html/isus/theme/default) [function.rename]: Directory not empty in /home/a5880517/public_html/isus/admin/theme.php on line 36

Link to comment
Share on other sites

OK i'm using same system but it's for the user so when the user logs in they theme changes to what they have set

 

ok i changed the code the file is called utheme.php and i think i got it right. Also make sure that you know that i want any user to be able to their own personal.

 

I just got an idea for the where could i go

 

$select = mysql_query("SELECT * FROM users WHERE username=$uName");

AND

$update = "UPDATE theme SET theme = '$utheme' WHERE username=$uName";

 

heres the utheme.php code

<?php

/*
iSuS User System User Theme Mod
Developed by: plasmagames(http://plasmasteelgames.net)
member of iScripting(http://iscripting.net/smf)
DO NOT REMOVE THIS
*/
//If the form hasn't been submitted, show it!
if (!$_POST['submit'])
{

    echo "<div class=\"reg\"><div class=\"point\"><img src=\"i/to.png\" alt=\"arrow\"><STRONG>Change Your Personal Theme<STRONG></div>
<center>
<form action='index.php?action=utheme' method='POST'>
<p><strong>Theme:</strong><input class=\"field\" type='text' style width='300' height='500' name='utheme' /></p>
<input class='submit' type='submit' name='submit' value='Change Theme' />
</form></center></div> ";
}
else
{
    //Or else it has.. Secure all the inputs
    $utheme = secure($_POST['utheme']);

    //find the old theme:
    $uselect = mysql_query("SELECT * FROM users WHERE theme");
    //u need a WHERE clause or it won't work and it has to be valid.
    $urow = mysql_fetch_array($select) or die(mysql_error());
    //call it $oldtheme
    $uoldtheme = $urow['utheme'];

    $utheme_dir = '/home/a5880517/public_html/isus/theme';


    if(file_exists($utheme_dir . "/$uoldtheme"))
    {
        //Insert the user information into the database
        $uupdate = "UPDATE theme SET theme = '$utheme' WHERE theme"; //u need a WHERE clause or it won't work and it has to be valid.
        $urename = rename("$utheme_dir/$uoldtheme", "$utheme_dir/$utheme");

        //If the update and rename went ok...
        if (mysql_query($uupdate) && $urename==true)
        {
            //Tell them the good news
            echo "The theme directory was changed to <br /> <strong>$theme</strong><br />";
        }
        else
        {
            echo "Error, the theme directory wasn't changed.";
        }
    }
    else
    {
        echo "The '$uoldtheme' does not exist in $utheme_dir";
    }
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.