Mam plik index.php:
<?php //Tells PhpBB we're not hackers. Includes the common.php file from the forums. $phpbb_root_path = '../forum/'; include($phpbb_root_path . 'common.' . $phpEx); // Start session management. This allows us access to some of the user's information when they are logged in. $user->session_begin(); $auth->acl($user->data); $user->setup(); //Some common thing's you'll use. $username gives the username, and $userid gives the unique ID of the loggedin user. $username = $user->data['username']; $userid = $user->data['user_id']; require_once 'config.php'; require_once SRC_DIR . 'functions.php'; $input = getInput(); require_once CLASS_DIR . 'class_mysql.php'; require_once CLASS_DIR . 'class_core.php'; $res = $db->query('SELECT * FROM `config`'); while(!$res->EOF) { $config[$res->field['name']] = $res->field['content']; $res->moveNext(); } $sess = new session; { $input['page'] = 'wiesci'; } else { { $input['page'] = 'wiesci'; } } require SUB_DIR . $input['page'] . '.php'; $screen = new SubPage($db, $sess, $config, $input); $screen->msg($message); // Po co niby destruktor... $screen->finalDisplay(); ?>
I jak mogę sprawić, żeby zmienne $username itd. działały także w innych plikach, np. class_core.php?
<?php class core { public $html = ''; public $db = NULL; public $sess = NULL; public $subpage; public $global_msg = ''; public $access; protected $online = null; public $noTemplate = 0; protected $groups = false; public function __construct($db, $sess, $config, $input) { $this->db = $db; $this->sess = $sess; $this->config = $config; $this->input = $input; $this->access = $this->getUserAccessLevel($user->data['site_id']); $this->loadSkin(); } public function finalDisplay() { $this->runSubPage(); if($this->config['page_enabled'] == 0 && !$this->config['disabled_page']) { } elseif($this->config['page_enabled'] == 0 && $this->config['disabled_page']) { exit; } if($this->noTemplate == 0) { $out = $this->tpl['page_index']; $out = str_replace('<%LOGIN_BOX%>' , $user->data['is_registered'] ? $this->tpl['loginbox_logged'] : $this->tpl['loginbox_not_logged'], $out); } else { $out = $this->getSubpageHtml(); } } private function loadSkin () { // Pobieramy glowny kod htmla z bazy $res = $this -> db -> select ( "html" ); while ( !$res -> EOF ) { $this -> tpl [$res -> field ['name']] = $res -> field ['html']; $res -> movenext(); } } function getSubpageHtml () { return $this -> html; } } ?>