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(); } $arResult = array(); $result = array(); $error = false; $ServiceID = intval($_REQUEST["serviceID"]); $status = htmlspecialcharsbx($_REQUEST["status"]); $selectedServices = array(); //Получим инфу о сервисе $result = \Hawkart\Megatv\ServiceTable::getById($ServiceID); $arService = $result->fetch(); //get subcribe channel list $result = \Hawkart\Megatv\SubscribeTable::getList(array('filter' => array("=UF_USER_ID" => $USER->GetID(), ">UF_SERVICE_ID" => 0), 'select' => array("UF_SERVICE_ID", "ID"))); while ($arSub = $result->fetch()) { $selectedServices[$arSub["UF_SERVICE_ID"]] = $arSub["ID"]; } //Если гугл или яндекс-диск и включен, то ничего не делаем if (isset($selectedServices[$ServiceID]) && $arService["UF_DISK_TYPE"]) { exit(json_encode(array("status" => "enable"))); } $CSubscribe = new \Hawkart\Megatv\CSubscribe("SERVICE"); //Если нет подписки или есть и + 5 или +10 ГБ if (!isset($selectedServices[$ServiceID]) || !$arService["UF_DISK_TYPE"]) { $result = $CSubscribe->setUserSubscribe($ServiceID); } else {
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } global $USER; CModule::IncludeModule("iblock"); $arResult["CHANNELS"] = array(); $selectedServices = array(); $arServices = array(); //get service subscribe list $result = \Hawkart\Megatv\SubscribeTable::getList(array('filter' => array("UF_ACTIVE" => 1, "=UF_USER_ID" => $USER->GetID(), ">UF_SERVICE_ID" => 0), 'select' => array("UF_SERVICE_ID"))); while ($arSub = $result->fetch()) { $selectedServices[] = $arSub["UF_CHANNEL_ID"]; } //get all services $result = \Hawkart\Megatv\ServiceTable::getList(array('filter' => array("UF_ACTIVE" => 1), 'select' => array("ID", "UF_TITLE", "UF_TEXT", "UF_PRICE", "UF_DISK_TYPE", "UF_DESC"))); while ($arService = $result->fetch()) { if (in_array($arService["ID"], $selectedServices)) { $arService["SELECTED"] = true; } $arServices[] = $arService; } $arResult["SERVICES"] = $arServices; $rsUser = CUser::GetByID($USER->GetID()); $arUser = $rsUser->Fetch(); $arResult["USER"] = $arUser; if (floatval($arResult["USER"]["UF_CAPACITY_BUSY"]) == 0 || floatval($arResult["USER"]["UF_CAPACITY"]) == 0) { $arResult["DISK_SPACE_FILLED"] = 0; } else { $arResult["DISK_SPACE_FILLED"] = round(floatval($arResult["USER"]["UF_CAPACITY_BUSY"]) / floatval($arResult["USER"]["UF_CAPACITY"]), 4); }
public function capacityAdd($SUBSCRIBE_TO, $USER_ID) { $result = \Hawkart\Megatv\ServiceTable::getById($SUBSCRIBE_TO); if ($arService = $result->fetch()) { $gb = IntVal($arService["UF_TEXT"]); } $gb = preg_replace("/[^0-9]/", '', $gb); if (intval($gb) > 0) { \CUserEx::capacityAdd($USER_ID, $gb); } }