Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 483 Vote(s) - 3.51 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Making your own MVC in PHP [Section 1]

#1
Most current popular MVCs do have many features that could and may suit you though its full of bloat content that you just simply don't need. In this general tutorial I'll be walking you through making a simple Model View Controller in PHP. I'll be writing this tutorial for Apache2 with AllowRewrite set to All for website directory.

By default on ubuntu/debain servers you'll need to go to /etc/apache2/apache2.conf and ctrl+w search "/var/www" and set AllowRewrite from None to All

How this MVC will work is using an auto-loader function to combine all the files and make them runnable inside index.php

To start off we'll need to make the .htaccess file, How this works it takes everything after / and returns it as a GET request.
.htaccess

Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


Now if you were to put in the index.php (Do not test this on a production server. Vulnerable to XSS Reflected.)
temp index.php

Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.

It will echo out what ever you put after domain.tld/blehblehkekbleh
Output: blehblehkekbleh

For this part we'll need to make a few directories even if they're left black in this section.
You'll need: class, controllers, views, and inc.

To finish off this tutorial we'll do the index, auto loader and route page so you can see progress.

index.php

Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.

It's requiring the auto-loader which will include all classes/controllers/etc.
The route is to get the correct page.

/inc/route.php

Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.

Now if you were to go to domain.tld you'd see "Hello world."
To add a new route you'd simply make another Route::Set

Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.

If you were to go to domain.tld/example you'd see "Hello world. 2"

The auto-loader use spl_autoload_register function to find all the classes, and is self explanatory. If you need help you can look at the documentation on PHP.net
/inc/autoload.php

Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.

With that it will look for all controllers and classes.
/class/route.class.php

Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


If you have any questions or need any help feel free to reply. I will continue to make more sections as I have time.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through