🤩 File Manager - Mr.X
PHP:
8.3.33
Server:
Apache
OS:
Linux 5.14.0-611.49.1.el9_7.x86_64
User:
websparkit
Navigate
Upload:
Upload
New File
New Folder
Editing:App.php
<?php /* * App Core Class * Creates URL & loads core controller * URL FORMAT - /controller/method/params */ class App { protected $currentController = 'Pages'; protected $currentMethod = 'index'; protected $params = []; public function __construct(){ $url = $this->getUrl(); // Look in controllers for first value using APPROOT absolute path if(isset($url[0]) && file_exists(APPROOT . '/controllers/' . ucwords($url[0]). '.php')){ // If exists, set as controller $this->currentController = ucwords($url[0]); // Unset 0 Index unset($url[0]); } // Require the controller using APPROOT absolute path require_once APPROOT . '/controllers/'. $this->currentController . '.php'; // Instantiate controller class $this->currentController = new $this->currentController; // Check for second part of url if(isset($url[1])){ // Check to see if method exists in controller if(method_exists($this->currentController, $url[1])){ $this->currentMethod = $url[1]; // Unset 1 index unset($url[1]); } } // Get params $this->params = $url ? array_values($url) : []; // Call a callback with array of params call_user_func_array([$this->currentController, $this->currentMethod], $this->params); } public function getUrl(){ if(isset($_GET['url'])){ $url = rtrim($_GET['url'], '/'); $url = filter_var($url, FILTER_SANITIZE_URL); $url = explode('/', $url); return $url; } return []; } }
Save Changes
Cancel
Create New File
Create New Folder