Understand the index file

melo lobo Posted in Beginning Developers 1 year ago

in this code:

define('OSSN_ALLOW_SYSTEM_START', TRUE);
require_once('system/start.php');
//page handler
$handler = input('h');
//page name
$page = input('p');

//check if there is no handler then load index page handler
if (empty($handler)) {
    $handler = 'index';
}
echo ossn_load_page($handler, $page);

why pass the parameter 'h' and 'p' in input and why 'h' and 'p' in particular and not another letter. and since input('h') = 'index' why when we put directly

ossn_load_page('index', $page);

instead of

ossn_load_page($handler, $page);

the code doesn't work

Replies
ph Angel Brown Replied 8 months ago

That is so helpful. Thanks for sharing! boston iron works

gb Memora blereceive Replied 1 year ago

As OSSN is a multi-page platform, it dynamically acquires the values of "h" and "p" from the user.
geometry dash meltdown

ma Melo lobo Replied 1 year ago

Yes, that's exactly what I'm doing. I'm studying the code line by line and file by file, even though it's not an easy task, but I'm persevering. I want to treat OSSN like a school. I've already learned a lot by studying your code, but the journey is still long. In the future, I want to be capable of developing secure, reliable, and modular applications like OSSN and perhaps even join your community.

I've also found an approach that recommends using the following tools:

Composer:
Dependency manager for PHP, allowing the installation and management of third-party libraries.
Twig:
PHP template engine, facilitating the separation of business logic and presentation.
Monolog:
Flexible logging library for PHP.
Swift Mailer:
Facilitates sending emails from your PHP application.
Doctrine ORM:
Object-Relational Mapping (ORM) tool for interacting with the database.
Guzzle:
Library for making HTTP requests, useful for interacting with external APIs.
PHPUnit:
Unit testing framework for PHP.
Carbon:
For simplified manipulation of dates and times in PHP.
Flysystem:
Abstract file system for PHP, useful for file management.
League\OAuth2:
Implements the OAuth2 protocol for authentication.
Slim Framework:
A PHP micro-framework for creating web applications and RESTful APIs.
PHP dotenv:
Loads environment variables from a .env file, facilitating configuration.

Indonesian Arsalan Shah Replied 1 year ago

$handler = 'index'; means the defaults value is index.

Changing those variables to something doesn't make sense for me. They are linked with Apache configurations should see rewrite rules in .htaccess file. And the variables changes with each different page you view.

Simply log those values and see they changes on different pages.

Again why you wanted to change that you wanted to do something specific? or looking for something specific? I guess you are just learning the code?

ma Melo lobo Replied 1 year ago

if you have time change the 'h' in input with another letter and see what happens to the site. it does not make sense. In principle the site must work despite this because $handler will always be empty because no argument is on the URL. however the site crashes. there is something wrong somewhere (I don't know is it in your code or in my brain)
NB: the same for 'p' the site crashes when we change it .

ma Melo lobo Replied 1 year ago

If the input() function appears to be designed to handle input data from the superglobal $_REQUEST by performing various operations such as cleaning, validation, and manipulation of data before using it in the code, why use it here? Additionally, in this case where $handler = 'index', why set $handler = input('h') instead of simply using 'index'?

ma Melo lobo Replied 1 year ago

Sorry, Arsalan, but you respond to me as if I were a member of your team or part of Openteknik. I'm a self-taught individual trying my luck in the big leagues. I would appreciate it if you could lower the level a bit and show more generosity in your explanations. I'm sorry, but I won't stop asking questions until I understand your renowned work

Indonesian Arsalan Shah Replied 1 year ago

Why h and p because h stands for handler and p stands for page

example multi level pages

group/view/.....

group is h andler
view/... is p age

Because OSSN is multi pages platform that is why its dynamicly get the value of h and p from user