<?PHP 

    # Пишу скрипты, модули с 0 
    # PHP <> 7.4, MySQL,MySQL(i),PDO
    # author penny wise
    # telegram @the_penny_wise

    # ядро

    require_once (__DIR__."/_sys/_core.php");

    $page = isset( $_GET['page'] ) ? abs(intval($_GET['page'])) : 0;

    $url = URL.'/films/top'.($page != 0 ? '&'.$page:'');

    $get = curl($url);

    $view = get_index($get);

    $title = ($view[0]->title != null ? $view[0]->title : 'ТОП фильмов за сегодня');
    $description = ($view[0]->description != null ? $view[0]->description : 'ТОП фильмов за сегодня');
    $t = 'ТОП фильмов за сегодня';
    
    # head

    require_once (__DIR__."/_sys/_head.php");

    # index

    if ($view[0]->title != null):

    foreach ($view as $data):

    if ($data->url != null):

    echo '
    <div class="my_razdel film">
	<a href="https://'.DOMAIN.'/films/'.$data->url.'"><div class="screenfilm">
    '.($data->new != null ? '<span class="newhit">'.$data->new.'</span>':'').'
	<br><img src="'.$data->src.'" alt="'.$data->sti.'" title="'.$data->sti.'"></div>
	<div class="opisfilm"><div class="namefilm">'.$data->name.'</div> 
    <span class="in green">'.$data->green.'</span> 
    <span class="in sound">'.$data->sound.'</span> 
    <span class="in year">'.$data->year.'</span> 
    <br>
    ';

    foreach ($view as $genre):

    echo ($genre->genre_url == $data->url ? '<span class="in genre">'.$genre->genre.'</span>':'');   

    endforeach;  

    echo '<br>
    <span class="discripfilm">'.$data->discripfilm.'</span></div>
	<div class="clear"></div></a></div>
    ';   

    endif;    

    endforeach;   

    echo '</div>';

    page_index($get);

    else: echo '</div><div class="us_msg" style="margin: 0px 4px;color: red;"><strong>Ошибка зайдите позже!</strong></div>'; endif;

    echo '
    <div class="menuniz">
    <a href="https://'.DOMAIN.'/films/search"><img src="https://'.DOMAIN.'/style/img/newpoisk.png" alt="">Поиск</a>
    <a href="https://'.DOMAIN.'"><img src="https://'.DOMAIN.'/style/img/back.png" alt="">На главную</a></div>
    ';

    # foot

    require_once (__DIR__."/_sys/_foot.php");