public function up()
 {
     global $APPLICATION;
     $arHlData = $this->arHlData;
     \Bitrix\Main\Loader::includeModule("highloadblock");
     $arHlblock = \Bitrix\Highloadblock\HighloadBlockTable::getList(array('filter' => array('TABLE_NAME' => \Hawkart\Megatv\RecordTable::getTableName())))->fetch();
     if ($arHlblock) {
         $oUserTypeEntity = new \CUserTypeEntity();
         $sort = 500;
         foreach ($arHlData['FIELDS'] as $fieldName => $fieldValue) {
             $aUserField = array('ENTITY_ID' => 'HLBLOCK_' . $arHlblock["ID"], 'FIELD_NAME' => $fieldName, 'USER_TYPE_ID' => $fieldValue[1], 'SORT' => $sort, 'MULTIPLE' => 'N', 'MANDATORY' => $fieldValue[0], 'SHOW_FILTER' => 'N', 'SHOW_IN_LIST' => 'Y', 'EDIT_IN_LIST' => 'Y', 'IS_SEARCHABLE' => 'N', 'SETTINGS' => array());
             if (isset($fieldValue[2]) && is_array($fieldValue[2])) {
                 $aUserField = array_merge($aUserField, $fieldValue[2]);
             }
             $resProperty = \CUserTypeEntity::GetList(array(), array('ENTITY_ID' => $aUserField['ENTITY_ID'], 'FIELD_NAME' => $aUserField['FIELD_NAME']));
             if ($aUserHasField = $resProperty->Fetch()) {
                 $idUserTypeProp = $aUserHasField['ID'];
                 if ($oUserTypeEntity->Update($idUserTypeProp, $aUserField)) {
                     $this->out('Обновлено свойство - ' . $fieldValue[2]['EDIT_FORM_LABEL']['ru']);
                 } else {
                     if ($ex = $APPLICATION->GetException()) {
                         $this->outError('Ошибка - ' . $ex->GetString());
                     }
                 }
             } else {
                 if ($idUserTypeProp = $oUserTypeEntity->Add($aUserField)) {
                     $this->out('Добавлено новое свойство - ' . $fieldValue[2]['EDIT_FORM_LABEL']['ru']);
                 } else {
                     if ($ex = $APPLICATION->GetException()) {
                         $this->outError('Ошибка - ' . $ex->GetString());
                     }
                 }
             }
             $sort += 100;
         }
         $arFilter = array();
         $arSelect = array("ID");
         $result = \Hawkart\Megatv\RecordTable::getList(array('filter' => $arFilter, 'select' => $arSelect));
         while ($arRecord = $result->fetch()) {
             \Hawkart\Megatv\RecordTable::update($arRecord["ID"], array('UF_DATETIME_ADD' => new \Bitrix\Main\Type\DateTime(date('Y-m-d H:i:s'), 'Y-m-d H:i:s')));
         }
         $oUserTypeEntity = new \CUserTypeEntity();
         $resProperty = \CUserTypeEntity::GetList(array(), array('ENTITY_ID' => 'HLBLOCK_' . $arHlblock["ID"], 'FIELD_NAME' => "UF_SOTAL_ID"));
         if ($aUserHasField = $resProperty->Fetch()) {
             $oUserTypeEntity->Delete($aUserHasField['ID']);
             $this->outSuccess("Свойство удалено!");
         }
         $this->outSuccess('Все готово на %d%%', 100);
     }
 }
Exemple #2
0
$rsUsers = \CUser::GetList($by = "LAST_NAME", $order = "asc", $filter, array("SELECT" => array("UF_CAPACITY_BUSY", "UF_CAPACITY"), "FIELDS" => array("ID", "EMAIL", "NAME")));
while ($arUser = $rsUsers->GetNext()) {
    //Если у пользователя есть программы, ожидающие записи
    if (isset($arUserRecords[$arUser["ID"]]) && !empty($arUserRecords[$arUser["ID"]])) {
        $ids = $arUserRecords[$arUser["ID"]];
        $Sotal = new \Hawkart\Megatv\CSotal($arUser["ID"]);
        $Sotal->getSubscriberToken();
        $arSchedules = $Sotal->getScheduleList();
        foreach ($arSchedules["schedule"] as $arSchedule) {
            $record_id = $arSchedule["id"];
            $status = $arSchedule["state"];
            if (intval($status) == 3 && in_array($record_id, $ids)) {
                $arStream = $Sotal->getStreamUrl($record_id);
                $url = $arStream["url"];
                if (!empty($url)) {
                    $arRecord = $arRecords[$record_id];
                    //Если достаточно пространства
                    if (intval($arUser["UF_CAPACITY_BUSY"]) < intval($arUser["UF_CAPACITY"])) {
                        \CNotifyEx::afterRecord(array("USER_ID" => $arUser["ID"], "USER_NAME" => $arUser["NAME"], "USER_EMAIL" => $arUser["EMAIL"], "RECORD_ID" => $arRecord["ID"], "RECORD_NAME" => $arRecord["NAME"], "PICTURE" => "http://tvguru.com" . $arRecord["PICTURE"]["SRC"], "URL" => "http://tvguru.com/personal/records/?record_id=" . $arRecord["ID"] . "&play=yes"));
                        \Hawkart\Megatv\RecordTable::update($arRecord["ID"], array("UF_URL" => $url, "UF_AFTER_NOTIFY" => 1));
                    }
                }
            }
        }
        unset($Sotal);
    }
}
unset($arUserRecords);
unset($arRecords);
echo "loaded";
die;
<?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;
Exemple #4
0
<?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();
}
$status = false;
$record_id = intval($_REQUEST["broadcastID"]);
if ($USER->IsAuthorized() && $record_id > 0 && $_REQUEST["delete"]) {
    $result = \Hawkart\Megatv\RecordTable::getById($record_id);
    $arRecord = $result->fetch();
    if ($arRecord["UF_USER_ID"] == $USER->GetID()) {
        $USER_ID = $USER->GetID();
        $rsUser = \CUser::GetByID($USER_ID);
        $arUser = $rsUser->Fetch();
        $arRecord["UF_DATE_START"] = $arRecord['UF_DATE_START']->toString();
        $arRecord["UF_DATE_END"] = $arRecord['UF_DATE_END']->toString();
        $duration = strtotime($arRecord["UF_DATE_END"]) - strtotime($arRecord["UF_DATE_START"]);
        $minutes = ceil($duration / 60);
        $gb = $minutes * (18.5 / 1024);
        $busy = floatval($arUser["UF_CAPACITY_BUSY"]) - $gb;
        $user = new \CUser();
        $user->Update($arUser["ID"], array("UF_CAPACITY_BUSY" => $busy));
        \Hawkart\Megatv\RecordTable::update($record_id, array("UF_DELETED" => 1));
        $status = "success";
    }
}
exit(json_encode(array("status" => $status)));
Exemple #5
0
 if ($budget < 0) {
     exit(json_encode(array("status" => "error", "error" => "Для записи передачи пополните счет.")));
 }
 //Провеим, хватит ли пространства!
 $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" => "Нельзя записать")));
Exemple #6
0
<?php

/**
 * Delete script
 */
$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";
header('Content-Type: text/html; charset=utf-8');
ini_set('mbstring.func_overload', '2');
ini_set('mbstring.internal_encoding', 'UTF-8');
global $USER, $APPLICATION;
if (!is_object($USER)) {
    $USER = new \CUser();
}
/**
 * Уведомление на email в момент начала записи
 */
$dt = new Bitrix\Main\Type\DateTime(date('Y-m-d H:i:s', time()), 'Y-m-d H:i:s');
$result = \Hawkart\Megatv\RecordTable::getList(array('filter' => array("UF_URL" => false, ">UF_DATE_START" => $dt, "<UF_DATE_END" => $dt, "!UF_BEFORE_NOTIFY" => 1), 'select' => array("ID", "UF_TITLE" => "UF_PROG.UF_TITLE", "UF_SUB_TITLE" => "UF_PROG.UF_SUB_TITLE", "UF_IMG_PATH" => "UF_PROG.UF_IMG.UF_PATH", "UF_USER_ID")));
while ($arRecord = $result->fetch()) {
    $arRecord["NAME"] = \Hawkart\Megatv\ProgTable::getName($arRecord);
    $arRecord["PICTURE"]["SRC"] = \Hawkart\Megatv\CFile::getCropedPath($arRecord["UF_IMG_PATH"], array(300, 300), true);
    \CNotifyEx::onRecord(array("USER_ID" => $arRecord["UF_USER_ID"], "RECORD_ID" => $arRecord["ID"], "PICTURE" => "http://megatv.su" . $arRecord["PICTURE"]["SRC"], "RECORD_NAME" => trim($arRecord["NAME"])));
    \Hawkart\Megatv\RecordTable::update($arRecord["ID"], array("UF_BEFORE_NOTIFY" => 1));
}
die;