Exemple #1
0
$APPLICATION->SetDirProperty('og_image', $arResult["PICTURE"]["SRC"]);
$APPLICATION->SetDirProperty('og_type', 'album');
//get status schedule
$arResult["STATUS"] = \Hawkart\Megatv\CScheduleTemplate::status(array("ID" => $arResult["ID"], "UF_CHANNEL_ID" => $arResult["UF_CHANNEL_ID"], "DATE_START" => $arResult["DATE_START"], "DATE_END" => $arResult["DATE_END"]));
foreach (array("UF_DIRECTOR", "UF_PRESENTER", "UF_ACTOR") as $type) {
    $_arResult[$type] = array();
    $arPeoples = explode(",", $arResult[$type]);
    foreach ($arPeoples as $actor) {
        $actor = trim($actor);
        if (!empty($actor)) {
            $link = \Hawkart\Megatv\PeopleTable::getKinopoiskLinkByName($actor);
            $link = str_replace("//name", "/name", $link);
            if (empty($link)) {
                $link = "#";
            }
            $_arResult[$type][] = array("NAME" => $actor, "LINK" => $link);
        }
    }
    $arResult[$type] = $_arResult[$type];
    unset($_arResult[$type]);
}
/**
 * Add data to statistics
 */
//\Hawkart\Megatv\CStat::channelAdd($arResult["UF_CHANNEL_ID"]);
$back_recommendations = false;
if (strpos($_SERVER['HTTP_REFERER'], "/recommendations/") !== false) {
    $back_recommendations = true;
}
\Hawkart\Megatv\CStat::addByShedule($arResult["ID"], "scheduleShow", $back_recommendations);
$this->IncludeComponentTemplate();
Exemple #2
0
                }
                unset($arRecommendSorted[$by_what][0]);
                $arRecommendSorted[$by_what] = array_values($arRecommendSorted[$by_what]);
                if (count($arRecommendSorted[$by_what]) == 0) {
                    $added = true;
                }
            }
        }
    }
} else {
    $arFilter["=UF_CHANNEL_ID"] = \Hawkart\Megatv\ChannelTable::getActiveIdByCity();
    $arResult["PROGS"] = getRecommendForAll($arFilter, $arSelect, $limit, $offset);
}
$arResult["CATEGORIES"] = array();
if ($USER->IsAuthorized()) {
    $arStat = \Hawkart\Megatv\CStat::getByUser($USER->GetID());
    foreach ($arStat["CATS"] as $category => $id) {
        $str = \CDev::translit($category, "ru", array("replace_space" => "-", "replace_other" => "-"));
        $arResult["CATEGORIES"][$category] = $str;
    }
} else {
    foreach ($arResult["PROGS"] as $key => $arProg) {
        $category = $arProg["UF_CATEGORY"];
        $str = \CDev::translit($category, "ru", array("replace_space" => "-", "replace_other" => "-"));
        $arResult["CATEGORIES"][$category] = $str;
    }
}
if ($_REQUEST["AJAX"] == "Y") {
    $APPLICATION->RestartBuffer();
    /**
     * Get records statuses by user
<?php

define('STOP_STATISTICS', true);
require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php';
$GLOBALS['APPLICATION']->RestartBuffer();
global $USER;
if (!is_object($USER)) {
    $USER = new \CUser();
}
$broadcastID = intval($_GET["broadcastID"]);
if ($_GET["record"] == "false") {
    $result = \Hawkart\Megatv\RecordTable::getList(array('filter' => array("=UF_USER_ID" => $USER->GetID(), "=UF_SCHEDULE_ID" => $broadcastID), 'select' => array("ID", "UF_PROGRESS_PERS", "UF_PROG_ID"), 'limit' => 1));
    if ($arRecord = $result->fetch()) {
        $broadcastID = $arRecord["ID"];
    }
}
$arFields = array("UF_PROGRESS_SECS" => intval($_GET["progressInSeconds"]), "UF_PROGRESS_PERS" => intval($_GET["progressPosition"]));
if (intval($_GET["progressPosition"]) > 3) {
    $arFields["UF_WATCHED"] = 1;
}
\Hawkart\Megatv\RecordTable::update($broadcastID, $arFields);
//add to statistic
//$qunatityQuanters = abs($arRecord["UF_PROGRESS_PERS"]-$arFields["UF_PROGRESS_PERS"]);
$qunatityQuanters = intval($arFields["UF_PROGRESS_PERS"]);
if ($qunatityQuanters > 0) {
    \Hawkart\Megatv\CStat::addByRecord($broadcastID, "quaterShow_" . $qunatityQuanters);
}
die;
<?php

$DOCUMENT_ROOT = $_SERVER["DOCUMENT_ROOT"] = realpath(dirname(__FILE__) . '/../');
define("NO_KEEP_STATISTIC", true);
define("NOT_CHECK_PERMISSIONS", true);
set_time_limit(0);
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
echo date("H:i:s") . "\r\n";
$arProgsByRating = \Hawkart\Megatv\ProgTable::getProgsByRating();
$rsUsers = CUser::GetList($by = "id", $order = "asc", array("ACTIVE" => "Y"), array("FIELDS" => array("ID")));
while ($arUser = $rsUsers->GetNext()) {
    $arStatistic = \Hawkart\Megatv\CStat::getByUser($arUser["ID"]);
    $arRecommend = array("by_ganres" => \Hawkart\Megatv\CStat::getProgsByGanre($arProgsByRating, $arStatistic), "by_users" => \Hawkart\Megatv\CStat::getTopRateProg($arProgsByRating), "by_records" => \Hawkart\Megatv\CStat::getTopRateSerialByUser($arUser["ID"], $arStatistic));
    $json = json_encode($arRecommend);
    \Hawkart\Megatv\CStat::saveRecommend($arUser["ID"], $json);
}
echo date("H:i:s") . "\r\n";
die;
Exemple #5
0
    $date_confing = date('d.m.Y', strtotime("+" . $i . " day", strtotime($fisrt_date)));
    $arResult["CONFIG_DATES"][] = $date_confing;
}
//Get channel list
$arChannels = array();
$arResult["ITEMS"] = \Hawkart\Megatv\ChannelTable::getActiveByCity();
foreach ($arResult["ITEMS"] as $arChannel) {
    $arChannels[$arChannel["UF_CHANNEL_BASE_ID"]] = $arChannel;
}
$arResult["ITEMS"] = $arChannels;
/**
 * sort channels for user according statistics
 */
if ($USER->IsAuthorized()) {
    $arItems = array();
    $arStatistic = \Hawkart\Megatv\CStat::getByUser();
    //sort channels by raiting
    uasort($arStatistic["CHANNELS"], function ($a, $b) {
        return strcmp($b, $a);
    });
    foreach ($arStatistic["CHANNELS"] as $channel_id => $rating) {
        if (!empty($arResult["ITEMS"][$channel_id])) {
            $arItems[] = $arResult["ITEMS"][$channel_id];
            unset($arResult["ITEMS"][$channel_id]);
        }
    }
    if (count($arResult["ITEMS"]) > 0) {
        $arItems = array_merge($arItems, $arResult["ITEMS"]);
    }
    $arResult["ITEMS"] = $arItems;
    unset($arItems);
Exemple #6
0
    $duration = strtotime($arSchedule["UF_DATE_END"]) - strtotime($arSchedule["UF_DATE_START"]);
    $minutes = ceil($duration / 60);
    $gb = $minutes * 18.5 / 1024;
    $busy = floatval($arUser["UF_CAPACITY_BUSY"]) + $gb;
    if ($busy >= floatval($arUser["UF_CAPACITY"])) {
        exit(json_encode(array("status" => "require-space", "error" => "Не достаточно места на диске для записи")));
    } else {
        if (in_array($arSchedule["UF_CHANNEL_BASE_ID"], $selectedChannels)) {
            $log_file = "/logs/sotal/sotal_" . date("d_m_Y_H") . ".txt";
            \CDev::log(array("ACTION" => "PUT_TO_RECORD", "DATA" => array("SCHEDULE_ID" => $prog_time, "DATE" => date("d.m.Y H:i:s"))), false, $log_file);
            if ($update) {
                \Hawkart\Megatv\RecordTable::update($update_id, array("UF_DELETED" => 0));
            } else {
                \Hawkart\Megatv\RecordTable::create($arSchedule);
            }
            //Inc rating for prog
            \Hawkart\Megatv\ProgTable::addByEpgRating($arSchedule["UF_PROG_EPG_ID"], 1);
            //change capacity for user
            $cuser = new \CUser();
            $cuser->Update($arUser["ID"], array("UF_CAPACITY_BUSY" => $busy));
            /**
             * Данные в статистику
             */
            \Hawkart\Megatv\CStat::addByShedule($arSchedule["ID"], "record");
            $status = "success";
        } else {
            exit(json_encode(array("status" => "error", "error" => "Нельзя записать")));
        }
    }
}
exit(json_encode(array("status" => $status)));