S
S
Sergey Bondarenko2019-01-29 20:10:03
PHP
Sergey Bondarenko, 2019-01-29 20:10:03

CNC problems?

In general, the essence of the problem is this: There is a PHP
code :

$url = explode('/',strtolower(substr($_SERVER['REQUEST_URI'], 1)));

switch($url[0]) {
    case 'Главная страница': { 
    include 'com/top.php';
    break;
 }
}

.htaccess
RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule . /index.php [L]

He actually does CNC.
So, let's say I made an ajax request and sent it to some kind of handler, the fact is that it opens the form itself, that is, an empty page with the handler itself, while ajax magically stops working, and most likely it is from -for cnc, because in order to use the same form handler, you need to enter it like this:
switch($url[0]) {
    case 'Какой-то обработчик': { 
    include 'com/form.php';
    break;
 }
}

Yes, and every time to enter a handler in these fields, I think it’s not Feng Shui ...
It doesn’t suit me, can handlers somehow bypass this CNC system?
Sorry for the bumps on my forehead due to facepalms, I'm still new to this business.
But you need to learn to understand this, so PAMAGITE!
Sirs, do not bypass this question!
Thank you very much in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Dart, 2019-01-29
@lietryit

Do not write a router yourself, install a ready-made one, for example Klein or Aura, it will give you some framework right away. Do you know how to work with composer?
So your router should be in index.php, and depending on what came into it, it should call one or another PHP file. Those. if a POST request comes in and the address specifies a form handler page, then just call the form handler file.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question