Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A couple of suggestions:</p> <ul> <li>Put your controller classes in its own dedicated folder, containing ONLY controller classes</li> <li><p>Make your filter as strict as possible eg.</p> <pre><code>/* is $_GET['controller'] set? */ if (!isset($_GET['controller'])) { // load error or default controller??? } $loadController = $_GET['controller']; /* replace any characters NOT matching a-z or _ (whitelist approach), case insensitive */ $loadController = preg_replace('/[^a-z_]+/i', '', $loadController); /* verify var is not empty now :) */ if (!$loadController) { // load error or default controller??? } /* if your classes are named in a certain fashion, eg. "Classname", format the incoming text to match ** NEVER TRUST USER INPUT ** */ $loadController = ucfirst(strtolower($loadController)); </code></pre></li> <li><p>Check if the file exists <a href="http://php.net/file_exists" rel="nofollow">Why not file_exists? see desc</a></p> <pre><code>/* avoiding using file_exists as it also matches folders... */ if (!is_file($myControllerClassesPath.$loadController.'.php')) { // load error or default controller??? } </code></pre></li> <li><p>Then require the file, and verify that the class itself exists</p> <pre><code>require($myControllerClassesPath.$loadController.'.php'); /* of course, this assumes filename === classname, adjust accordingly */ if (!class_exists($loadController)) { // load error or default controller??? } </code></pre></li> <li><p>Then of course, new instance of X</p> <pre><code>new $loadController; </code></pre></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload