SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Wizard mark_W's Avatar
    Join Date
    Mar 2004
    Location
    West Midlands, United Kingdom
    Posts
    2,631
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Look over this please!

    Hey Guys....again!

    I just threw this together, I know its nothing like a proper page controller but it works for me. CAn anyone see any issues with this code?

    Thanks

    PHP Code:

    class pageController {

        var 
    $page;
        var 
    $plugin;
        var 
    $dir;
        var 
    $file;
        
        function 
    pageController() {
        
            
    $this->page $_GET['page'].'.php';
            
    $this->plugin $_GET['page'];
            
    $this->dir 'lib/plugins/';
            
    $this->file $this->dir $this->page;
        
        }
        
        function 
    pageExists() {
        
                if(
    file_exists("$this->file")) {
                    
    $this->pageRedirect();
            } else {
                
    $this->errorRedirect();
            }
        }
        
        function 
    pageRedirect() {
        
            switch (
    $this->plugin) {
                case 
    "$this->plugin":
                include(
    "$this->dir"."$this->page");
                break;

            }

        }
        
        function 
    errorRedirect() {
        
                include(
    "$this->dir"."error.php");
                
        }
        


  2. #2
    SitePoint Wizard mark_W's Avatar
    Join Date
    Mar 2004
    Location
    West Midlands, United Kingdom
    Posts
    2,631
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, found a few errors myself.... new code

    PHP Code:

    class pageController {

        var 
    $page;      // Holds plugin name .php ext
        
    var $plugin;    // Holds plugin name
        
    var $def;       // Holds default plugin
        
    var $dir;       // Holds plugins dir
        
    var $file;      // Holds plugin filename
        
        
    function pageController() {
        
            @
    $this->page $_GET['page'].'.php';
            @
    $this->plugin $_GET['page'];
            
    $this->def 'news.php';
            
    $this->dir 'lib/plugins/';
            
    $this->file $this->dir $this->page;
        
        }
        
        function 
    pageExists() {
        
            if(!(
    $this->plugin)) {
                    
    $this->defaultRedirect();
            } else {
                if(
    file_exists("$this->file")) {
                        
    $this->pageRedirect();
                } else {
                    
    $this->errorRedirect();
                }
            }
        }
        
        function 
    pageRedirect() {
        
            switch (
    $this->plugin) {
                case 
    "$this->plugin":
                include(
    "$this->dir"."$this->page");
                break;
                
                default:
                include(
    "$this->dir"."$this->def");
                break;
            }

        }
        
        function 
    defaultRedirect() {

                include(
    "$this->dir"."$this->def");

        }
        
        function 
    errorRedirect() {
        
                include(
    "$this->dir"."error.php");
                
        }
        



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •