Jump to content

benanamen

Members
  • Posts

    2,134
  • Joined

  • Last visited

  • Days Won

    42

Posts posted by benanamen

  1. Thanks for your feedback.

     

    Oh. And for SEO you shouldn't use basename as that creates the opportunity for accessing a page through multiple URLs, which is not good.

     

    This is only used in DB backend applications requiring logging in so SEO is of no concern.

  2. I would like feedback on this basic single site entry procedural code. Any issues, improvements or comments? (included in index.php)

    <?php
    /*
     * This file: display_pages.php
     * Acts as a Router to display pages
     * Restricts access to certain files
     *
     */
    
    //------------------------------------------------------------------------
    // Restrict access to these files
    //------------------------------------------------------------------------
    
    // Specify some disallowed paths
    $restricted_files = array(
        'header',
        'footer',
        'navbar',
        'menu',
    );
    
    //----------------------------------------------------------------------------------------
    // Display Pages
    //----------------------------------------------------------------------------------------
    
    if (isset($_GET['p']))
        {
    
        $page = basename($_GET['p']);
    
        // If it's not a disallowed path, and if the file exists
        if (!in_array($page, $restricted_files) && file_exists("./includes/$page.php"))
            {
            $include = "./includes/$page.php";
            }
        else
            {
            $include = './includes/404.php';
            }
        }
    else
        {
        $include = './includes/default.php';
        }
    ?>
    
  3. Since your autoloader indiscriminately tries to include "classes/*.class.php",

     

    Is the manual example a bad usage?

     

    What else is there to know... about the code you posted? About autoloading in general? PSR-4? Namespaces? 

     

    Question was regarding the autoloader. I want to know it inside and out before I go on the the next item.

  4. RE: spl_autoload_register

     

    I am using the example code from the manual and it works.

    spl_autoload_register(function ($class) {
        include 'classes/' . $class . '.class.php';
    });
    
    
    $valid_login = new LoginAttemptsLog($pdo);
    $valid_login->logSuccessfulAttempt('new_goodusername');
    

    Through testing I see that it somehow reads new LoginAttemptsLog into $class and thinks it is a filename to look for in the classes directory. Do I need to understand anything more than this? What else is there to know about this?

×
×
  • 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.