Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

issue with dynamic properties

56 views
Skip to first unread message

Jeffrey Röling

unread,
Mar 13, 2024, 6:21:36 PM3/13/24
to Fat-Free Framework
After an upgrade of my webserver I got this issue, anyone a idea what this could be?
Screenshot 2024-03-13 at 23.18.00.png

The part of the script I also added.
<?php
// Hocus Pocus, grab the focus
// Magic. Do not touch.

class Controller {

function beforeroute() {
// Inactivity Check
if( $this->f3->get('SESSION.granted') ) {
if( time() - $this->f3->get('SESSION.timestamp') > $this->f3->get('auto_logout') ) {
$this->f3->clear('SESSION');
$this->f3->reroute('@home');
} else {
$this->f3->set('SESSION.timestamp', time());
}
}
// CSRF Prevention
if( NULL === $this->f3->get('POST.token') ){
$this->f3->CSRF = $this->f3->session->csrf();
$this->f3->copy('CSRF','SESSION.csrf');
}
if( $this->f3->VERB === 'POST' ){
if( $this->f3->get('POST.token') == $this->f3->get('SESSION.csrf') ) {
// Thing check out! No CSRF attack was detectd.
$this->f3->set('CSRF', $this->f3->session->csrf()); // Reset CSRF token vor next post request.
$this->f3->copy('CSRF','SESSION.csrf'); // Copy the token to the variable.
} else {
// DANGER: CSRF Attack!
$this->flash->addMessage($this->f3->get('DICT.csrf'), 'danger');
$this->f3->reroute('@home');
}
}

// Access Control
$access = \Access::instance();
$access->policy('allow'); // Allow access to all routes by default.
$somebody = $this->f3->exists('SESSION.user.group') ? $this->f3->get('SESSION.user.group') : 0;
$access->authorize($somebody, function($route,$subject){
$this->flash->addMessage($this->f3->get('DICT.accessDenied'), 'danger');
$this->f3->reroute('@home');
});

// Database insert/edit validation
$this->validator->loadLang();

$this->validator->onError(function($text,$key) {
$this->f3->set('error.'.$key, $text);
$this->flash->addMessage($text,'danger');
});
}

function __construct(){
$this->f3 = \Base::instance();
$this->db = new DB\SQL("mysql:host=" . $this->f3->get("database.host") . ";port=" . $this->f3->get("database.port") . ";dbname=" . $this->f3->get("database.name"),$this->f3->get("database.user"),$this->f3->get("database.pass"), array(\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION));
$this->f3->set('DB',$this->db); // Set DB keys for Cortex
$this->template = \Template::instance();
$this->flash = \Flash::instance();
$this->validator = \Validation::instance();
$this->today = date("Y-m-d H:i:s");
$this->pushbullet = new \Pushbullet\Pushbullet($this->f3->get('pushbullet.apikey'));
}

}
Message has been deleted

Guido Canella

unread,
Mar 14, 2024, 4:33:48 AM3/14/24
to Jeffrey Röling via Fat-Free Framework
As of PHP 8, you cannot use class properties that you haven't declared before.
For example, this is deprecated:

class Foo {
    function __construct() {
        $this->bar = 1;
    }
}

You must add declaration:

class Foo {
    public $bar;
    function __construct() {
        $this->bar = 1;
    }
}

Or, you can use attributes:

#[AllowDynamicProperties]
class Foo {
    function __construct() {
        $this->bar = 1;
    }
}


Cheers.


--
-- You've received this message because you are subscribed to the Google Groups group. To post to this group, send an email to f3-fra...@googlegroups.com. To unsubscribe from this group, send an email to f3-framework...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/f3-framework?hl=en
---
You received this message because you are subscribed to the Google Groups "Fat-Free Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to f3-framework...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/f3-framework/dcf7881b-36e1-4900-8485-411ae858fee9n%40googlegroups.com.

Jeffrey Röling

unread,
Mar 16, 2024, 3:32:09 PM3/16/24
to Fat-Free Framework
Add the controller.php I added in de class controller the vars used in __construct() that seems to do the trick.

See below "home"
<?php
// Hocus Pocus, grab the focus
// Magic. Do not touch.

namespace Controllers\Pages;

class Home extends \Controller {

public function index() {
$this->f3->set('title', $this->f3->get('DICT.nav.home'));
$this->f3->set('view', 'app/pages/home/index.htm');

// Setup Database
//\Models\Materials\Items::setup();
//\Models\Materials\Categories::setup();
//\Models\Materials\Borrowers::setup();
//\Models\Materials\Issues::setup();
//\Models\Materials\Sections::setup();

//\Models\Reservations\Reservation::setup();
//\Models\Reservations\Seasons::setup();

echo $this->template->render('templates/default/layout.htm');
}
}



Reply all
Reply to author
Forward
0 new messages