<commit_before><?php
session_start();

ob_start();

include "../common.php";
include "../lib/func.php";

$error = '';

$db = Database::getInstance();

moderator_access();

echo '<pre>';
//print_r($_FILES);
//print_r($_SESSION);
//print_r($_POST);
echo '</pre>';

$search = @$_GET['search'];
$letter = @$_GET['letter'];
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">

body {
    font-family: Arial, Helvetica, sans-serif;
    font-weight: bold;
}
td {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    text-decoration: none;
    color: #000000;
}
.list{
    border-width: 1px;
    border-style: solid;
    border-color: #E5E5E5;
}
a{
	color:#0000FF;
	font-weight: bold;
	text-decoration:none;
}
a:link,a:visited {
	color:#5588FF;
	font-weight: bold;
}
a:hover{
	color:#0000FF;
	font-weight: bold;
	text-decoration:underline;
}
</style>
<title>
Статистика просмотра ВИДЕО по жанрам за месяц
</title>
</head>
<body>
<table align="center" border="0" cellpadding="0" cellspacing="0">
<tr>
    <td align="center" valign="middle" width="100%" bgcolor="#88BBFF">
    <font size="5px" color="White"><b>&nbsp;Статистика просмотра ВИДЕО по жанрам за месяц&nbsp;</b></font>
    </td>
</tr>
<tr>
    <td width="100%" align="left" valign="bottom">
        <a href="stat_video.php"><< Назад</a>
    </td>
</tr>
<tr>
    <td align="center">
    <font color="Red">
    <strong>
    <? echo $error?>
    </strong>
    </font>
    <br>
    <br>
    </td>
</tr>
<tr>
<td>
<?
function count_rate($sarr){
    if (is_array($rate = unserialize($sarr))){
        return array_sum($rate);
    }else{
        return 0;
    }
}

function page_bar(){
    global $MAX_PAGE_ITEMS;
    global $page;
    global $total_pages;
    
    $page_bar = '';

    for($i = 1; $i <= $total_pages; $i++){
        if(($i-1) != $page){
            $page_bar .= ' <a href="?page='.($i-1).'&search='.@$_GET['search'].'&letter='.@$_GET['letter'].'">'.$i.'</a> |';
        }
        else
        {
            $page_bar .= '<b> '.$i.' </b>|';
        }
    }
    return $page_bar;
}

$from = date("Y-m-d H:i:s", time()-60*60*24*30);

$query = "select count(played_video.id) as played_counter, genre.title as genre_title from played_video left join video on played_video.video_id=video.id inner join genre on genre.id=genre_id_1 or genre.id=genre_id_2 or genre.id=genre_id_3 or genre.id=genre_id_4 where playtime>'$from' group by genre.title";
//echo $query;
$rs = $db->executeQuery($query);

echo "<center><table class='list' cellpadding='3' cellspacing='0'>\n";
echo "<tr>";
echo "<td class='list'><b>Жанр</b></td>\n";
echo "<td class='list'><b>Просмотров</b></td>\n";
echo "</tr>\n";
while(@$rs->next()){
    
    $arr=$rs->getCurrentValuesAsHash();
    
    echo "<tr>";
    echo "<td class='list'>".$arr['genre_title']."</td>\n";
    echo "<td class='list'>".$arr['played_counter']."</td>\n";
    echo "</tr>\n";
}
echo "</table>\n";
echo "<table width='700' align='center' border=0>\n";
echo "<tr>\n";
echo "<td width='100%' align='center'>\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</center>\n";<commit_msg>Added total genres statistic (issue #560)<commit_after><?php
session_start();

ob_start();

include "../common.php";
include "../lib/func.php";

$error = '';

$db = Database::getInstance();

moderator_access();

echo '<pre>';
//print_r($_FILES);
//print_r($_SESSION);
//print_r($_POST);
echo '</pre>';

$search = @$_GET['search'];
$letter = @$_GET['letter'];
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">

body {
    font-family: Arial, Helvetica, sans-serif;
    font-weight: bold;
}
td {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    text-decoration: none;
    color: #000000;
}
.list{
    border-width: 1px;
    border-style: solid;
    border-color: #E5E5E5;
}
a{
	color:#0000FF;
	font-weight: bold;
	text-decoration:none;
}
a:link,a:visited {
	color:#5588FF;
	font-weight: bold;
}
a:hover{
	color:#0000FF;
	font-weight: bold;
	text-decoration:underline;
}
</style>
<title>
Статистика просмотра ВИДЕО по жанрам за месяц
</title>
</head>
<body>
<table align="center" border="0" cellpadding="0" cellspacing="0">
<tr>
    <td align="center" valign="middle" width="100%" bgcolor="#88BBFF">
    <font size="5px" color="White"><b>&nbsp;Статистика просмотра ВИДЕО по жанрам за месяц&nbsp;</b></font>
    </td>
</tr>
<tr>
    <td width="100%" align="left" valign="bottom">
        <a href="stat_video.php"><< Назад</a>
    </td>
</tr>
<tr>
    <td align="center">
    <font color="Red">
    <strong>
    <? echo $error?>
    </strong>
    </font>
    <br>
    <br>
    </td>
</tr>
<tr>
<td>
<?
function count_rate($sarr){
    if (is_array($rate = unserialize($sarr))){
        return array_sum($rate);
    }else{
        return 0;
    }
}

function page_bar(){
    global $MAX_PAGE_ITEMS;
    global $page;
    global $total_pages;
    
    $page_bar = '';

    for($i = 1; $i <= $total_pages; $i++){
        if(($i-1) != $page){
            $page_bar .= ' <a href="?page='.($i-1).'&search='.@$_GET['search'].'&letter='.@$_GET['letter'].'">'.$i.'</a> |';
        }
        else
        {
            $page_bar .= '<b> '.$i.' </b>|';
        }
    }
    return $page_bar;
}

$genres = Mysql::getInstance()->from('genre')->get()->all();

$from = date("Y-m-d H:i:s", time()-60*60*24*30);

//$query = "select count(played_video.id) as played_counter, genre.title as genre_title from played_video left join video on played_video.video_id=video.id inner join genre on genre.id=genre_id_1 or genre.id=genre_id_2 or genre.id=genre_id_3 or genre.id=genre_id_4 where playtime>'$from' group by genre.title";
//echo $query;
//$rs = $db->executeQuery($query);

echo "<center><table class='list' cellpadding='3' cellspacing='0'>\n";
echo "<tr>";
echo "<td class='list'><b>Жанр</b></td>\n";
echo "<td class='list'><b>Просмотров</b></td>\n";
echo "<td class='list'><b>Всего фильмов</b></td>\n";
echo "<td class='list'><b>%</b></td>\n";
echo "</tr>\n";
//while(@$rs->next()){
foreach ($genres as $genre){

    //$arr=$rs->getCurrentValuesAsHash();

    $total_movies_in_genre = Mysql::getInstance()
        ->from('video')
        ->count()
        ->where(array('genre_id_1' => $genre['id'], 'genre_id_2' => $genre['id'], 'genre_id_3' => $genre['id'], 'genre_id_4' => $genre['id']), 'OR ')
        ->get()
        ->counter();

    //Mysql::$debug = true;

    $played_movies_in_genre = Mysql::getInstance()
        ->from('played_video')
        ->count()
        ->join('video', 'video.id', 'played_video.video_id', 'left')
        ->where(array('playtime>' => $from))
        ->where(array('genre_id_1' => $genre['id'], 'genre_id_2' => $genre['id'], 'genre_id_3' => $genre['id'], 'genre_id_4' => $genre['id']), 'OR ')
        ->get()->counter();

    $ratio = $total_movies_in_genre == 0 ? 0 : round(($played_movies_in_genre / $total_movies_in_genre)*100, 2);

    echo "<tr>";
    //echo "<td class='list'>".$arr['genre_title']."</td>\n";
    echo "<td class='list'>".$genre['title']."</td>\n";
    echo "<td class='list'>".$played_movies_in_genre."</td>\n";
    echo "<td class='list'>".$total_movies_in_genre."</td>\n";
    echo "<td class='list'>".$ratio."</td>\n";
    echo "</tr>\n";
}
echo "</table>\n";
echo "<table width='700' align='center' border=0>\n";
echo "<tr>\n";
echo "<td width='100%' align='center'>\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</center>\n";
{'fraction_non_alphanumeric': 0.23685608072225173, 'fraction_numerical': 0.018720127456186935, 'mean_word_length': 3.6586270871985156, 'pattern_counts': {'":': 0, '<': 165, '<?xml version=': 0, '>': 190, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2261815', 'n_tokens_mistral': 3070, 'n_tokens_neox': 2973, 'n_words': 574}