PHP Classes

File: mvc.php

Recommend this page to a friend!
  Classes of Piotr Malinski   punFramework   mvc.php   Download  
File: mvc.php
Role: Auxiliary script
Content type: text/plain
Description: Framework main file for calling controllers
Class: punFramework
MVC framework to extend punBB discussion boards
Author: By
Last change:
Date: 17 years ago
Size: 2,019 bytes
 

Contents

Class file image Download
<?php
// punBB things
define('PUN_PAGE', 'viewforum');
define('PUN_ROOT', './');
define('PUN_ALLOW_INDEX', 1);
require
PUN_ROOT.'include/common.php';
$page_nav = 'punFramework | <a href="index.php">Go to Forum</a>';
$page_title = $lang_common['Forum index'];
require
PUN_ROOT.'header.php';
//require PUN_ROOT.'lang/'.$pun_user['language'].'/search.php';

// punFramework start
include_once PUN_ROOT.'punFramework/punRoot.class.php';
include_once
PUN_ROOT.'punFramework/punController.class.php';
$db->db_type = $db_type;

IF(isset(
$_GET['c']) and is_file(PUN_ROOT.'punFramework/controllers/'.$_GET['c'].'.php') and ctype_alpha($_GET['c']))
    {
    try
        {
        include_once
PUN_ROOT.'punFramework/controllers/'.$_GET['c'].'.php';
       
// If method specified try to use it
       
IF(isset($_GET['m']) and ctype_alpha($_GET['m']))
            {
           
$action = new $_GET['c']($pun_user, $db, $pun_config, $pun_url, $lang_common);
            IF(
method_exists($action, $_GET['m']))
                {
                echo
$action->$_GET['m']();
                }
            else
                {
                throw new
Exception('Non existing class method: '.$_GET['m'].' for class: '.$_GET['c']);
                }
            }
        else
            {
           
//no method specified, use default "index" method
           
$action = new $_GET['c']($pun_user, $db, $pun_config, $pun_url, $lang_common);
            echo
$action->index();
            }
        }
    catch (
Exception $er)
        {
       
$wskaz = @fopen('debug.php', 'a');
        @
fwrite($wskaz, 'Error Message: '.$er->getMessage()."\n\r File: ".$er->getFile()."\n\r Row: ".$er->getLine()."\n\rIP: ".$_SERVER['REMOTE_ADDR']."\n\r URL".$_SERVER['REQUEST_URI']."\n\rBackTrace: \n\r".$er->getTraceAsString()."\n\r############################################\n\r");
        @
fclose($wskaz);
       
message('<b>Script Error! Full error message have been logged.</b>');
        }
    }
elseIF(isset(
$_GET['c']) and !is_file(PUN_ROOT.'punFramework/controllers/'.$_GET['c'].'.php') and ctype_alpha($_GET['c']))
    {
   
message('Controller file does not exist');
    }
else
    {
   
message('No Controller/Module Parameters / Other errors');
    }

// pun end
require PUN_ROOT.'footer.php';