K
K
Kristina87872020-02-25 15:26:42
PHP
Kristina8787, 2020-02-25 15:26:42

Why did index.php stop opening on open server?

Hello. I recently started learning PHP, I did everything exactly according to the video tutorial, at first everything worked, but today index.php stopped opening, removed the checks, left only the body, still does not open, the rest of the site files open and even the captcha works. I open through open server , apache 2.4 .

<?


if ( $_SERVER['REQUEST_URI'] == '/' ) $page = 'home';
else {

  $page = substr($_SERVER['REQUEST_URI'], 1);
  if ( !preg_match('/^[A-z0-9]{3,15}$/', $page) ) exit('error url');
}


session_start();



if ( file_exists('all/'.$page.'.php') ) include 'all/'.$page.'.php';

else if ( $_SESSION['ulogin'] == 1 and file_exists('auth/'.$page.'.php') ) include 'auth/'.$page.'.php';

else if ( $_SESSION['ulogin'] != 1 and file_exists('guest/'.$page.'.php') ) include 'guest/'.$page.'.php';

else exit('Страница 404');


function message( $text ) {
  exit('{ "message" : "'.$text.'"}');
}



function go( $url ) {
  exit('{ "go" : "'.$url.'"}');
}


function captcha_show() {

  $questions = array(
    1 => 'Столица России ?',
    2 => 'Столица Украины ?',
    3 => 'Столица США ?',
    4 => 'Имя короля поп музыки ?',
    5 => 'Разработчки GTA 5 ?',
    );

  $num = mt_rand(1, count($questions) );
  $_SESSION['captcha'] = $num;

  echo $questions[$num];

}

function captcha_valid() {

  $answers = array(
    1 => 'моска',
    2 => 'киев',
    3 => 'вашингтон',
    4 => 'майкл',
    5 => 'RockStarGames',
    );

if ( $_SESSION['captcha'] != array_search( strtolower($_POST['captcha']), $answers) )
  message('Ответ на вопрос указан не верно');

}

function top( $title ) {
echo '<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>'.$title.'</title>
<link rel="stylesheet" href="/style.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<script src="https://code.jquery.com/jquery-1.12.4.js" integrity="sha256-Qw82+bXyGq6MydymqBxNPYTaUXXq7c8v3CwiYwLLNXU=" crossorigin="anonymous"></script>
<script src="/script.js"></script>
</head>

<body>
<div class="wrapper">
<div class="menu">
<a href="/">Главная</a>
<a href="/login">Вход</a>
<a href="/register">Регистрация</a>
</div>
<div class="content">
<div class="block">
';
}

function bottom() {
echo '
</div>
</div>
</div>
</body>
</html>';
}

?>


Gives out "page 404", if I remove this check, then nothing at all gives out, just a blank page. Help me to understand

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Ninazu, 2020-02-25
@Ninazu

1. Which path are you trying to get to the page?
2. Is there an all/home.php file ?
3. What's in .htaccess ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question