예제 #1
0
 /**
  * Get videos from youtube for each tv channel
  */
 public function importForChannels()
 {
     self::deletePics();
     $arBaseChannels = array();
     $result = \Hawkart\Megatv\ChannelBaseTable::getList(array('filter' => array("UF_ACTIVE" => 1), 'select' => array("ID", "UF_YOUTUBE"), 'order' => array("ID" => "ASC")));
     while ($row = $result->fetch()) {
         $arUrls = array();
         $ar = explode(";", $row["UF_YOUTUBE"]);
         foreach ($ar as $url) {
             $url = trim($url);
             if (!empty($url)) {
                 $arUrls[] = $url;
             }
         }
         if (count($arUrls) > 0) {
             $arBaseChannels[$row["ID"]] = $arUrls;
         }
     }
     foreach ($arBaseChannels as $channel_id => $arUrls) {
         $file = self::getFilePathByChannel($channel_id);
         $arVideos = array();
         foreach ($arUrls as $url) {
             $arVideos = array_merge($arVideos, $this->getArVideosByUrl($url));
         }
         self::save($arVideos, $file);
     }
 }
예제 #2
0
 public function pay($SUBSCRIBE_TO, $USER_ID = false)
 {
     global $USER;
     if (!$USER_ID) {
         $USER_ID = $USER->GetID();
     }
     if ($this->type == "CHANNEL") {
         $result = \Hawkart\Megatv\ChannelBaseTable::getById($SUBSCRIBE_TO);
         if ($arService = $result->fetch()) {
             $price = IntVal($arService["UF_PRICE_H24"]);
         }
     } else {
         $result = \Hawkart\Megatv\ServiceTable::getById($SUBSCRIBE_TO);
         if ($arService = $result->fetch()) {
             $price = IntVal($arService["UF_PRICE"]);
         }
     }
     if ($price == 0) {
         return true;
     }
     if ($price > 0 && \CSaleAccountEx::budget($USER_ID) > $price) {
         $comment = "Оплата подписки на " . $arService["TTILE"];
         if (!\CSaleAccountEx::transaction(-1 * $price, $USER_ID, $comment)) {
             return false;
         }
     } else {
         return false;
     }
     return true;
 }
예제 #3
0
 public function down()
 {
     global $APPLICATION;
     $arHlData = $this->arHlData;
     \Bitrix\Main\Loader::includeModule("highloadblock");
     $arHlblock = \Bitrix\Highloadblock\HighloadBlockTable::getList(array('filter' => array('TABLE_NAME' => \Hawkart\Megatv\ChannelBaseTable::getTableName())))->fetch();
     if ($arHlblock) {
         foreach ($arHlData as $fieldName => $fieldValue) {
             $oUserTypeEntity = new \CUserTypeEntity();
             $resProperty = \CUserTypeEntity::GetList(array(), array('ENTITY_ID' => 'HLBLOCK_' . $arHlblock["ID"], 'FIELD_NAME' => $fieldName));
             if ($aUserHasField = $resProperty->Fetch()) {
                 $oUserTypeEntity->Delete($aUserHasField['ID']);
                 $this->outSuccess("Свойство 'Дата добавления' удалено!");
             }
         }
     }
 }
예제 #4
0
 public static function getBaseChannels()
 {
     $arBaseChannels = array();
     $result = \Hawkart\Megatv\ChannelBaseTable::getList(array('filter' => array("UF_ACTIVE" => 1), 'select' => array("ID", "UF_YOUTUBE"), 'order' => array("ID" => "ASC")));
     while ($row = $result->fetch()) {
         $arUrls = array();
         $ar = explode(";", $row["UF_YOUTUBE"]);
         foreach ($ar as $url) {
             $url = trim($url);
             if (!empty($url)) {
                 $arUrls[] = $url;
             }
         }
         if (count($arUrls) > 0) {
             $arBaseChannels[$row["ID"]] = $arUrls;
         }
     }
     $this->arBaseChannels = $arBaseChannels;
 }
예제 #5
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
global $USER;
$arResult["CHANNELS"] = array();
$selectedChannels = array();
$arChannels = array();
//get subsribe channel list
$result = \Hawkart\Megatv\SubscribeTable::getList(array('filter' => array("UF_ACTIVE" => 1, "=UF_USER_ID" => $USER->GetID(), ">UF_CHANNEL_ID" => 0), 'select' => array("UF_CHANNEL_ID")));
while ($arSub = $result->fetch()) {
    $selectedChannels[] = $arSub["UF_CHANNEL_ID"];
}
$result = \Hawkart\Megatv\ChannelBaseTable::getList(array('filter' => array("UF_ACTIVE" => 1), 'select' => array("ID", "UF_TITLE", "UF_ICON", "UF_PRICE_H24"), 'order' => array("UF_PRICE_H24" => "DESC", "UF_TITLE" => "ASC")));
while ($arChannel = $result->fetch()) {
    if (in_array($arChannel["ID"], $selectedChannels)) {
        $arChannel["SELECTED"] = true;
    }
    $arChannels[] = $arChannel;
}
$arResult["CHANNELS"] = $arChannels;
$this->IncludeComponentTemplate();
예제 #6
0
파일: ajax.php 프로젝트: Hawkart/megatv
$GLOBALS['APPLICATION']->RestartBuffer();
global $USER;
if (!is_object($USER)) {
    $USER = new CUser();
}
$result = array();
$channelID = intval($_REQUEST["channelID"]);
$status = htmlspecialcharsbx($_REQUEST["status"]);
//get subcribe channel list
$selectedChannels = array();
$result = \Hawkart\Megatv\SubscribeTable::getList(array('filter' => array("=UF_USER_ID" => $USER->GetID(), ">UF_CHANNEL_ID" => 0), 'select' => array("UF_CHANNEL_ID", "ID")));
while ($arSub = $result->fetch()) {
    $selectedChannels[$arSub["UF_CHANNEL_ID"]] = $arSub["ID"];
}
//check disable sub
$result = \Hawkart\Megatv\ChannelBaseTable::getList(array('filter' => array("=UF_FORBID_REC" => 1, "=ID" => $channelID), 'select' => array("ID")));
if ($arChannel = $result->fetch()) {
    exit(json_encode(array("status" => "disable", "error" => "Нельзя подписаться на канал")));
}
//update subsribes
$CSubscribe = new \Hawkart\Megatv\CSubscribe("CHANNEL");
if (!isset($selectedChannels[$channelID])) {
    $result = $CSubscribe->setUserSubscribe($channelID);
} else {
    if ($status == "enable") {
        $active = 1;
    } else {
        $active = 0;
    }
    $subscribeID = $selectedChannels[$channelID];
    $result = $CSubscribe->updateUserSubscribe($subscribeID, array("UF_ACTIVE" => $active));
예제 #7
0
파일: cepg.php 프로젝트: Hawkart/megatv
 /**
  * Download file xml from EPG service to server
  *
  */
 public function importChannels()
 {
     $arHrefChannels = array();
     $arBaseChannels = array();
     $result = ChannelBaseTable::getList(array('filter' => array(), 'select' => array("UF_EPG_ID", "ID", "UF_ACTIVE"), 'order' => array("ID" => "ASC")));
     while ($row = $result->fetch()) {
         if ($arBaseChannels[$row["UF_EPG_ID"]]["ID"] > 0) {
             ChannelBaseTable::delete($row["ID"]);
             //if dublicate exist
         } else {
             $arBaseChannels[$row["UF_EPG_ID"]] = $row;
         }
     }
     $arChannels = array();
     $result = ChannelTable::getList(array('filter' => array("!UF_EPG_ID" => false), 'select' => array("UF_EPG_ID", "ID", "UF_BASE_ID")));
     while ($row = $result->fetch()) {
         $arChannels[$row["UF_EPG_ID"]] = $row;
     }
     foreach ($this->xml->channel as $_arChannel) {
         $attr = $_arChannel->{'base-channel'}->attributes();
         $base_epg_id = trim((string) $attr["id"]);
         $json = json_encode($_arChannel);
         $arChannel = json_decode($json, TRUE);
         $epg_id = trim((string) $arChannel["@attributes"]["id"]);
         $name = trim((string) $arChannel["display-name"]);
         $base_title = trim((string) $arChannel["base-channel"]);
         $icon = (string) $arChannel["@attributes"]["src"];
         $href = trim((string) $arChannel["href"]);
         $arHrefChannels[$epg_id][] = $href;
         if (!empty($base_epg_id) && $base_epg_id != $epg_id) {
             ChannelBaseTable::delete($epg_id);
             unset($arBaseChannels[$epg_id]);
             if (!is_array($arBaseChannels[$base_epg_id])) {
                 $arFields = array("UF_ACTIVE" => 0, "UF_EPG_ID" => $base_epg_id, "UF_TITLE" => trim((string) $arChannel["base-channel"]));
                 $result = ChannelBaseTable::add($arFields);
                 if ($result->isSuccess()) {
                     $id = $result->getId();
                     $arFields["ID"] = $id;
                     $arBaseChannels[$base_epg_id] = $arFields;
                 } else {
                     $errors = $result->getErrorMessages();
                 }
             }
         } else {
             if (!is_array($arBaseChannels[$epg_id])) {
                 $arFields = array("UF_ACTIVE" => 0, "UF_EPG_ID" => $epg_id, "UF_TITLE" => $name);
                 $result = ChannelBaseTable::add($arFields);
                 if ($result->isSuccess()) {
                     $id = $result->getId();
                     $arFields["ID"] = $id;
                     $arBaseChannels[$epg_id] = $arFields;
                 } else {
                     $errors = $result->getErrorMessages();
                 }
             }
         }
         if (!is_array($arChannels[$epg_id])) {
             if (empty($base_epg_id)) {
                 $base_epg_id = $epg_id;
             }
             $arFields = array("UF_EPG_ID" => $epg_id, "UF_BASE_ID" => $arBaseChannels[$base_epg_id]["ID"]);
             $result = ChannelTable::add($arFields);
             if ($result->isSuccess()) {
                 $id = $result->getId();
                 $arFields["ID"] = $id;
                 $arChannels[$epg_id] = $arFields;
             } else {
                 $errors = $result->getErrorMessages();
             }
         }
         if (empty($base_epg_id)) {
             $base_epg_id = $epg_id;
         }
         $arChannels[$epg_id]["UF_BASE_EPG_ID"] = $base_epg_id;
     }
     $this->base_channels = $arBaseChannels;
     $this->channels = $arChannels;
     $this->href_channels = $arHrefChannels;
     return $arChannels;
 }
예제 #8
0
파일: CUserEx.php 프로젝트: Hawkart/megatv
 public function subcribeOnFreeChannels($user_id = false)
 {
     global $USER;
     if (!$user_id && $USER->IsAuthorized()) {
         $user_id = $USER->GetID();
     }
     if (intval($user_id) > 0) {
         $result = \Hawkart\Megatv\ChannelBaseTable::getList(array('filter' => array("UF_ACTIVE" => 1, "!UF_PRICE_H24" => true, "!UF_FORBID_REC" => 1), 'select' => array("ID")));
         while ($arChannel = $result->fetch()) {
             $CSubscribe = new \Hawkart\Megatv\CSubscribe("CHANNEL");
             $CSubscribe->setUserSubscribe($arChannel["ID"], $user_id);
         }
     }
 }
예제 #9
0
파일: sitemap.php 프로젝트: Hawkart/megatv
$date = date("Y-m-d");
$xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">";
$html = '<!DOCTYPE html>
<html>
<head>
</head>
<body>

<ul>
    <li><a href="http://tvguru.com/">Программа телепередач на сегодня</a></li>
    <li><a href="http://tvguru.com/recommendations/">Рекомендации</a></li>
    <li>Каналы:<ul>
';
$arFilter = array("UF_ACTIVE" => 1);
$arSelect = array("ID", "UF_TITLE", "UF_CODE");
$result = \Hawkart\Megatv\ChannelBaseTable::getList(array('filter' => $arFilter, 'select' => $arSelect, 'order' => array("UF_SORT" => "ASC")));
while ($arChannel = $result->fetch()) {
    $html .= '<li><a href="http://tvguru.com/channels/' . $arChannel["UF_CODE"] . '/">' . $arChannel["UF_TITLE"] . '</a><ul>';
    /*$ids = array();
      
      $result_sh = \Hawkart\Megatv\ScheduleTable::getList(array(
          'filter' => array(
              "=UF_CHANNEL.UF_BASE_ID" => $arChannel["ID"],
              "=UF_PROG.UF_ACTIVE" => 1,
          ),
          'select' => array(
              "ID", "UF_ID" => "UF_PROG.UF_EPG_ID", "UF_CHANNEL_CODE" => "UF_CHANNEL.UF_BASE.UF_CODE",
              "UF_NAME" => "UF_PROG.UF_TITLE", "UF_SUB_NAME" => "UF_PROG.UF_SUB_TITLE",
          )
      ));
      while ($arSchedule = $result_sh->fetch())