e107inc / e107

e107 Bootstrap CMS (Content Management System) v2 with PHP, MySQL, HTML5, jQuery and Twitter Bootstrap. Issue Discussion Room: https://gitter.im/e107inc/e107
https://e107.org
GNU General Public License v3.0
320 stars 213 forks source link

[Feature request]: move some functions from class2.php to core_functions.php #5263

Open Jimmi08 opened 4 months ago

Jimmi08 commented 4 months ago

Motivation

Possibility to use e107::getInstance()->initCore() directly without class2.php (see example in thumb.php)

But there are some functions that are needed in handlers and they are now in class2.php:

For now:

function check_email($email) function check_class($var, $userclass = null, $uid = 0) function cookie($name, $value, $expire = 0, $path = e_HTTP, $domain = '', $secure = 0)

Proposed Solution

Could be those functions moved to core_functions.php file? Thanks

Alternatives

only workaround like separate file with those functions

Additional Context

No response

rica-carv commented 4 months ago

Just a dumb ideia: Use traits?

Jimmi08 commented 4 months ago

Just a dumb ideia: Use traits?

No, if you use e107 object without class2 file, there are still handlers that use classes from class2.php (without control if they exist) so you need to add them manually. But there is already a file for this... I don't see the reason why they need to be in class2 file if they are really core functions.

Vodhin commented 3 months ago

From what I understand class2.php is the security of your website: It performs checks on all traffic to the rest of e107 in order to prevent bad actors from causing trouble. You really should not use any php scripts without loading class2.php first, and since it is loaded the functions in that file are available for use anywhere further down the load chain.

Jimmi08 commented 3 months ago

@Vodhin look at thumb.php file. You don't need class2.php to use e107 handlers. e107 class is required.

Security is done in handlers too. Class2.php is needed only for the theme and front end. class2.php just combine calling those handlers.

I don't ask for security changes. It is more semantic. If there is file core functions why those functions are in class2.php if class2.php or e107 class still loads this file? That file is a mandatory file.