Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

HELP! - Got an issue i dont know how to resolve...

Featured Replies

Hi guys,

 

dont know if anyone can assist me but im having an issue with something

 

i have the following error on no matter what page i go to

Fatal error: Class 'Page' not found in /var/www/clients/client2/web17/web/includes/index/index.php on line 7

 

Heres the code for that line

<?php

include "includes/portfolio/required.php";
include "includes/blog/required.php";

//laters evil ted
class Index extends Page {

   public function output(){
    $this->setTitle("Welcome");
    global $mysqli;
       $this->startOutput();
?>

 

and class Page is like this

 

abstract class Page {
//Stuff Here
}

 

any help would be great

  • Author

hi ocorrieododiogo the Class Page is located in out includes/global/page.php and contains the abstract class then that page uses

<?=$this->output?>

 

to pull the pages in

 

Structure is

 

- Includes

-global

page.php

-index

index.php

 

heres my index page from the web root

<?
error_reporting(E_ALL);
ini_set("display_errors", "true");
//die(ini_get("upload_max_filesize"));
session_start();
if(!isset($_GET['dir'])) $_GET['dir']="index";
if(!isset($_GET['p'])) $_GET['p']="index";
function __autoload($class_name) {
$file="includes/{$_GET['dir']}/{$_GET['dir']}.php";
   $altFile="includes/{$_GET['dir']}/{$_GET['p']}.php";
if(file_exists($file))
 require_once $file;
   elseif(file_exists($altFile))
    require_once $altFile;
else
 die("$file $class_name<br />404");
}
function recurseDir($dir){
   if ($handle = opendir($dir)) {
    $dirs=$files=array();
    while (false !== ($file = readdir($handle))) {
	    if ($file != "." && $file != "..") {
		    if(is_dir("$dir/$file")) $dirs[]="$dir/$file";
		    else $files[]="$dir/$file";
	    }
    }
    closedir($handle);
    sort($files);//includes files starting with 0 as they are most important etc
    sort($dirs);
    foreach($dirs as $d) recurseDir($d);
    foreach($files as $f) require_once $f;
   }
}
recurseDir ("includes/global");
if(isset($_POST['getParsedBBCode'])) {
   echo parseBB($_POST['getParsedBBCode']);
   exit;
}
include "includes/globalVars.php";
$user=User::Singleton();
$c=null; //the page which gets set in the next switch
//print_r($_GET);
switch($_GET['dir']){
case 'about': $c=new About(); break;
case 'contact' : $c=new Contact(); break;
   case 'blog' : $c=new Blog(); break;
   case 'portfolio' : $c=new Portfolio(); break;
   case 'services' : $c=new Services(); break;
   case 'rss' :
    include "includes/rss/rss.php";
    break;
   case 'reg' : $c=new Reg(); break;
   case 'activate' : $c=new Activate; break;
   case 'members' : $c=new Members(); break;

case 'login': $c=User::Singleton(); break;
   case 'rearm-yourself': require_once("includes/register/register.php");
case 'register': $c=new Register(); break;
case 'cpanel': $c=new Cpanel(); break;	
case 'logout':
 User::Singleton()->logout();
 $c=new Index();
 /*$c->JSONExtra(array("usermenu"=>array(
  "panels"=>$c->getMenu(true),
  "links"=>$c->getMenuLinks(true)
 )));*/
 break;
   case "E404": $c=new ErrNotFound(); break;
default:$c=new Index();
}
if($c != null)
   $c->output(); //call the output function on the page made in the switch
?>

which then uses a switch statement to determine which page to load by the url GET variable.

 

on page.php where the abstract class Page { is

 

<?
//must .... commment..... argh.....
abstract class Page {
private $title = '';
   private $titleChanged = false;
private $head = '';
private $output='';
private $JSON_Extra=array();
private $outputBuf='';
private $extraJS=array();
   private $breadcrumb=array();

   private $outputCallbacks=array();
   public $dontTrackThisPage = false;

   public function registerOutputCallback($callback){
    $this->outputCallbacks[] = $callback;
   }

   private function fireOutputCallbacks(){
    if(!$this->dontTrackThisPage)
	    $_SESSION['previous'] = array("url"=>$_SERVER["REQUEST_URI"], "get"=>$_GET);
    foreach($this->outputCallbacks as $callback){
	    call_user_func($callback);
    }
   }

abstract protected function output();

protected function getJSONExtra(){
 return $this->JSON_Extra;
}

protected function JSONExtra(Array $arr){
 foreach($arr as $k=>$v) $this->JSON_Extra[$k]=$v;
}

/**
 * @param string $javascriptSource Source of the javascript file to include exluding the JS directory! so just the name probably
 */
public function addJS($javascriptSource){
    if(is_array($javascriptSource)) {
	    foreach($javascriptSource as $itm)
		    $this->addJS($itm);
	    return;
    }
    if(in_array($javascriptSource, $this->extraJS)) return;
 $this->extraJS[] = $javascriptSource;
}

   /**
   * Add an item to the list
   *
   * @param string $text the text to display
   * @param string $url the url to point to
   */
   protected function addBreadcrumb($text, $url) {
    $this->breadcrumb[] = array("text"=>$text, "url"=>$url);
   }

protected function setTitle($val){
 $this->title = $val . " - The Design Gurus";
}

protected function startOutput(){
 $this->outputBuf = ob_get_clean();
 ob_start();
}

protected function endOutput(){
    $this->fireOutputCallbacks();
 $content = ob_get_clean();
 ob_start();
 $this->output .= $this->outputBuf . $content;

 $this->outputBuf='';
 $this->outputHTML();
}

public function redirect($url,$force=false){
    $this->fireOutputCallbacks();
 if(isset($_POST['HIJAX'])){
	    ob_end_clean();
  if($force)
   $this->JSONExtra(array("force"=>true));

  $arr = $this->JSON_Extra;
  $arr['redir']=$url;
  echo json_encode($arr);
 } else {
  header("Location: " . $url);
 }
 exit;
}

   public function cause404(){
    $this->fireOutputCallbacks();
    ob_end_clean();
    header("Status: 404 Not Found");

    require_once("includes/error/E404.php");
    $e = new Index();
    $e->output();
    exit;
   }

protected function outputJSON() {
    $this->fireOutputCallbacks();
    ob_end_clean();
 echo json_encode($this->JSON_Extra);
 exit;
}

   private function getBreadcrumbHtml() {
    $html="";
    for($i=0, $c=count($this->breadcrumb); $i < $c; $i++)
	    $html .= ($this->breadcrumb[$i]['url'] != "" ? '<a href="' . $this->breadcrumb[$i]['url'] . '">' : '') .
				    $this->breadcrumb[$i]['text'] .
				 ($this->breadcrumb[$i]['url'] != "" ? '</a>' : "") . ($i < $c-1 ? " > " : "");
    return $html;
   }

protected function outputHTML(){
    if(User::Singleton()->loggedIn)
	    $this->addJS("cpanel.js");
    if(User::Singleton()->userLevel == User::ADMIN)
	    $this->addJS("bbcode.js");

 ob_start();
 if(isset($_POST['HIJAX'])){
  $arr = $this->JSON_Extra;
  $arr["content"]=$this->output;
  $arr["title"]=$this->title;
	    $arr["breadcrumb"]=$this->getBreadcrumbHtml();
	    if(count($this->extraJS) > 0)
		    $arr["extraJS"] = $this->extraJS;

  echo json_encode($arr);
 } else {		   
?>
//HTML output here and the <?=$this->output?> line to get the relevant page

 

hope this helps

The other files in the global directory being included? create a test.php there with a testing variable and try to call it from the index

 

// includes/global/test.php
<?php

$testVar = "hello!"

 

// includes/index/index.php
<?php

include "includes/portfolio/required.php";
include "includes/blog/required.php";

print $testVar;

 

does it print?

Edited by ocorreiododiogo

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.