Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP class not found
    primarykey
    data
    text
    <p>I solved this question my own. The filename was wrong lolz.</p> <p>Hello everyone!</p> <p>I'm building a CMS like Drupal and Joomla. I'm working on the module feature (plugins), and I got the following error:</p> <pre><code>Fatal error: Class 'settings' not found in C:\wamp\www\SYSTEM\view.php on line 22 </code></pre> <p>Here is my code:</p> <p>start.php</p> <pre><code>&lt;?php //First of all, start with some advertisement header("X-Powered-By:ZOMFG CMS, and ofcourse PHP, but that's less important"); //Then less impotant stuff lololol. session_start(); //Start a session mysql_connect($db_host, $db_user, $db_pass); //Connect to database mysql_select_db($db_name); //Select a database //Load core require_once("core.php"); //Load modules $res_modules = mysql_query("SELECT * FROM ".$_SERVER["db_prefix"]."modules WHERE enabled=1"); echo mysql_error(); $module_exists = array(); while($row_modules = mysql_fetch_array($res_modules)) { //Load module $name = $row_modules["name"]; modules::load_module($name); //and initialize it eval($name."::init();"); //Yes, it exists $module_exists[$name] = true; } //Check if the user wants shit from a module if(isset($_GET["m"]))//Yes the user want it { //Does the module exist and activated, and has it a function called view? if(isset($module_exists[$_GET["m"]]) &amp;&amp; method_exists($_GET["m"], "view"))//Yep { //Load view (should be an array) eval("\$module_view = ".$_GET["m"]."::view();"); if(!is_array($module_view))//Not an array :( { error::e500module($_GET["m"], $_SERVER["REQUEST_URI"]); } else//The error would kill the entire script, m'kay { view::index(); } } else//Nope, so display error { error::e404($_SERVER['REQUEST_URI']); } } </code></pre> <p>settings.php</p> <pre><code>&lt;?php class settings { function get($what) { $result_get = mysql_query("SELECT value FROM ".$_SERVER["db_prefix"]."settings WHERE key='$what'"); if(mysql_num_rows($result_get) &gt; 0) { $row_get = mysql_fetch_array($result_get); return $result_get["value"]; } else { return -1; } } } </code></pre> <p>core.php</p> <pre><code>&lt;?php //Load core classes require_once("settings.php"); require_once("error.php"); require_once("theme.php"); require_once("view.php"); require_once("modules.php"); </code></pre> <p>view.php</p> <pre><code>&lt;?php class view { function head() { include("../THEMES/".settings::get("theme")."/head.php"); } function foot() { include("../THEMES/".settings::get("theme")."/foot.php"); } function left() { include("../THEMES/".settings::get("theme")."/left.php"); } function right() { include("../THEMES/".settings::get("theme")."/right.php"); } function index() { include("../THEMES/".settings::get("theme")."/index.php"); } } </code></pre> <p>Start.php is obviously executed first. Not other pages are executed before it, except customsettings.php that contains database information. If I used $_SERVER["db_prefix"] in my code above, it's because I needed a superglobal which is set in customsettings.php:</p> <p>customsettings.php</p> <pre><code>&lt;?php $db_host = "localhost"; //Database host $db_user = "root"; //Database user $db_pass = "you may not know this"; //Database password $db_name = "zomfg"; //Database name $_SERVER["db_prefix"] = "zomfg_";//Prefix, needs to be superglobal </code></pre> <p>Can anybody help me? It seems that view.php's index function is called before settings.php is included. Sorry if this question is huge, I just want to be clear. Also don't say eval() is evil, I know.</p> <p>So I want to know why the settings class could not be found. If you need more source code, please comment to this question.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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