Exemplo n.º 1
0
 /**
  * Delete schedule before prev day
  */
 public static function deleteOld()
 {
     $result = self::getList(array('filter' => array("<UF_DATE" => new \Bitrix\Main\Type\Date(date('Y-m-d', strtotime('-2 day')), 'Y-m-d')), 'select' => array("ID")));
     while ($row = $result->fetch()) {
         ScheduleTable::delete($row["ID"]);
     }
 }
Exemplo n.º 2
0
function getRecommendForAll($arFilter, $arSelect, $limit, $offset)
{
    $arProgs = array();
    $result = \Hawkart\Megatv\ScheduleTable::getList(array('filter' => $arFilter, 'select' => $arSelect, 'order' => array("UF_PROG.UF_RATING" => "DESC"), 'limit' => 12, 'offset' => $offset));
    while ($arSchedule = $result->fetch()) {
        $arSchedule["UF_DATE_START"] = $arSchedule["DATE_START"] = \CTimeEx::dateOffset($arSchedule['UF_DATE_START']->toString());
        $arSchedule["UF_DATE_END"] = $arSchedule["DATE_END"] = \CTimeEx::dateOffset($arSchedule['UF_DATE_END']->toString());
        $arSchedule["UF_DATE"] = $arSchedule["DATE"] = substr($arSchedule["DATE_START"], 0, 10);
        $arSchedule["DETAIL_PAGE_URL"] = "/channels/" . $arSchedule["UF_CHANNEL_CODE"] . "/" . $arSchedule["UF_PROG_CODE"] . "/?event=" . $arSchedule["ID"];
        $arProgs[] = $arSchedule;
    }
    return $arProgs;
}
Exemplo n.º 3
0
 public function down()
 {
     global $APPLICATION;
     \Bitrix\Main\Loader::includeModule("highloadblock");
     $arHlblock = \Bitrix\Highloadblock\HighloadBlockTable::getList(array('filter' => array('TABLE_NAME' => \Hawkart\Megatv\ScheduleTable::getTableName())))->fetch();
     if ($arHlblock) {
         $arProps = array("UF_DATETIME_CREATE", "UF_DATETIME_EDIT");
         foreach ($arProps as $prop_name) {
             $oUserTypeEntity = new \CUserTypeEntity();
             $resProperty = \CUserTypeEntity::GetList(array(), array('ENTITY_ID' => 'HLBLOCK_' . $arHlblock["ID"], 'FIELD_NAME' => $prop_name));
             if ($aUserHasField = $resProperty->Fetch()) {
                 $oUserTypeEntity->Delete($aUserHasField['ID']);
                 $this->outSuccess("Свойство 'Дата добавления' удалено!");
             }
         }
     }
 }
Exemplo n.º 4
0
 /**
  * Connect serials & channels by prog schedules
  */
 public static function connectToChannels()
 {
     $arSerials = array();
     $result = self::getList(array('filter' => array("!UF_EPG_ID" => false), 'select' => array("UF_EPG_ID", "ID", "UF_CHANNEL_ID")));
     while ($row = $result->fetch()) {
         $arSerials[$row["UF_EPG_ID"]] = $row;
     }
     $arSerialChannels = array();
     $result = ScheduleTable::getList(array('filter' => array("=UF_CHANNEL.UF_BASE.UF_ACTIVE" => 1, "=UF_PROG.UF_ACTIVE" => 1), 'select' => array("SID" => "UF_PROG.UF_EPG_ID", "CHANNEL_BASE_ID" => "UF_CHANNEL.UF_BASE_ID")));
     while ($arSchedule = $result->fetch()) {
         $arSerialChannels[$arSchedule["SID"]][] = $arSchedule["CHANNEL_BASE_ID"];
     }
     foreach ($arSerialChannels as $epg_id => $arChannels) {
         $arSerial = $arSerials[$epg_id];
         if (intval($arSerial["ID"]) > 0) {
             $channel_ids = array_merge((array) $arSerial["UF_CHANNEL_ID"], $arChannels);
             $channel_ids = array_unique($channel_ids);
             self::update($arSerial["ID"], array("UF_CHANNEL_ID" => $channel_ids));
         }
     }
 }
Exemplo n.º 5
0
}
global $USER, $APPLICATION;
$arResult = array();
$arParams = $arParams + array("DATETIME" => \CTimeEx::getDatetime(), "LIST_URL" => $APPLICATION->GetCurDir(), "BACK_URL" => $_SERVER['HTTP_REFERER']);
if (empty($_REQUEST["event"])) {
    $arFilter = array("=UF_PROG.UF_CODE" => $arParams["ELEMENT_CODE"]);
} else {
    $arFilter = array("=ID" => $_REQUEST["event"]);
}
$arSelect = array("ID", "UF_DATE_START", "UF_DATE_END", "UF_DATE", "UF_CHANNEL_ID", "UF_PROG_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_RATING" => "UF_PROG.UF_RATING", "UF_DESC" => "UF_PROG.UF_DESC", "UF_SUB_DESC" => "UF_PROG.UF_SUB_DESC", "UF_TOPIC" => "UF_PROG.UF_GANRE", "UF_YEAR_LIMIT" => "UF_PROG.UF_YEAR_LIMIT", "UF_COUNTRY" => "UF_PROG.UF_COUNTRY", "UF_YEAR" => "UF_PROG.UF_YEAR", "UF_DIRECTOR" => "UF_PROG.UF_DIRECTOR", "UF_PRESENTER" => "UF_PROG.UF_PRESENTER", "UF_ACTOR" => "UF_PROG.UF_ACTOR", "UF_ICON" => "UF_CHANNEL.UF_BASE.UF_ICON", "UF_CATEGORY" => "UF_PROG.UF_CATEGORY");
$obCache = new \CPHPCache();
if ($obCache->InitCache(86400, serialize($arFilter) . serialize($arSelect), "/schedule-detail/")) {
    $arResult = $obCache->GetVars();
} elseif ($obCache->StartDataCache()) {
    //get channel by code
    $result = \Hawkart\Megatv\ScheduleTable::getList(array('filter' => $arFilter, 'select' => $arSelect, 'limit' => 1));
    if ($arResult = $result->fetch()) {
        $arResult["UF_DATE_START"] = $arResult["DATE_START"] = \CTimeEx::dateOffset($arResult['UF_DATE_START']->toString());
        $arResult["UF_DATE_END"] = $arResult["DATE_END"] = \CTimeEx::dateOffset($arResult['UF_DATE_END']->toString());
        $arResult["UF_DATE"] = $arResult["DATE"] = substr($arResult["DATE_START"], 0, 10);
        $arResult["PICTURE"]["SRC"] = \Hawkart\Megatv\CFile::getCropedPath($arResult["UF_IMG_PATH"], array(600, 600));
        $sec = strtotime($arResult["DATE_END"]) - strtotime($arResult["DATE_START"]);
        $arResult["DURATION"] = \CTimeEx::secToStr($sec);
        $arResult["KEYWORDS"] = array($arResult["UF_CATEGORY"], $arResult["UF_TOPIC"]);
    }
    $obCache->EndDataCache($arResult);
}
//redirect if error
if (intval($arResult["ID"]) == 0) {
    if (!empty($arFilter["=UF_PROG.UF_CODE"])) {
        CHTTP::SetStatus("404 Not Found");
Exemplo n.º 6
0
$query = htmlspecialcharsbx($_REQUEST["query"]);
$dateStart = date("Y-m-d H:00:00");
$arFilter = array("=UF_PROG.UF_ACTIVE" => 1, ">=UF_DATE_START" => new \Bitrix\Main\Type\DateTime($dateStart, 'Y-m-d H:i:s'), '%UF_PROG.UF_TITLE' => strtolower($query));
//User subscribe channel list
if ($USER->IsAuthorized()) {
    $arFilter["=UF_CHANNEL_ID"] = \Hawkart\Megatv\ChannelTable::getActiveIdByCityByUser();
} else {
    $arFilter["=UF_CHANNEL_ID"] = \Hawkart\Megatv\ChannelTable::getActiveIdByCity();
}
$arSelect = array("ID", "UF_CODE", "UF_DATE_START", "UF_TITLE" => "UF_PROG.UF_TITLE", "UF_SUB_TITLE" => "UF_PROG.UF_SUB_TITLE", "UF_IMG_PATH" => "UF_PROG.UF_IMG.UF_PATH", "UF_CHANNEL_CODE" => "UF_CHANNEL.UF_BASE.UF_CODE", "UF_ID" => "UF_PROG.UF_EPG_ID", "UF_PROG_CODE" => "UF_PROG.UF_CODE");
$obCache = new \CPHPCache();
if ($obCache->InitCache(3600, serialize($arFilter) . serialize($arSelect), "/search-ajax/")) {
    $arResult = $obCache->GetVars();
} elseif ($obCache->StartDataCache()) {
    $arExclude = array();
    $result = \Hawkart\Megatv\ScheduleTable::getList(array('filter' => $arFilter, 'select' => $arSelect, 'order' => array("UF_PROG.UF_RATING" => "DESC")));
    while ($arSchedule = $result->fetch()) {
        if (in_array($arSchedule["UF_ID"], $arExclude)) {
            continue;
        } else {
            $arExclude[] = $arSchedule["UF_ID"];
        }
        $arSchedule["UF_DATE_START"] = $arSchedule["DATE_START"] = $arSchedule['UF_DATE_START']->toString();
        $arJson = array();
        $arJson["date"] = substr($arSchedule["UF_DATE_START"], 11, 5) . " | " . substr($arSchedule["UF_DATE_START"], 0, 10);
        $arJson["title"] = $arSchedule["UF_TITLE"];
        if ($arSchedule["UF_IMG_PATH"]) {
            $src = \Hawkart\Megatv\CFile::getCropedPath($arSchedule["UF_IMG_PATH"], array(300, 300));
            //$renderImage = CFile::ResizeImageGet($src, Array("width"=>60, "height"=>60));
            $arJson["thumbnail"] = $src;
        } else {
Exemplo n.º 7
0
 /**
  * Clear tables & deleting images
  */
 public static function clear()
 {
     ProgTable::deleteAll();
     ScheduleTable::deleteAll();
     //ChannelTable::deleteAll();
     ImageTable::deleteAll();
     \CDev::deleteOldFiles($_SERVER["DOCUMENT_ROOT"] . self::$cut_dir, 0);
     \CDev::deleteOldFiles($_SERVER["DOCUMENT_ROOT"] . self::$origin_dir, 0);
 }
Exemplo n.º 8
0
 /**
  * Import all serials href from resource to db 
  */
 public static function importSerials()
 {
     $arToFile = array();
     $file_50_60 = $_SERVER['DOCUMENT_ROOT'] . "/upload/serials_50_60.txt";
     /**
      * Get all prog which are serials
      */
     $arSerials = array();
     $date_prevprev = date('Y-m-d', strtotime("-2 day"));
     $arFilter = array(">=UF_DATE_START" => new \Bitrix\Main\Type\DateTime($date_prevprev . " 00:00:00", 'Y-m-d H:i:s'), "<UF_DATE_START" => new \Bitrix\Main\Type\DateTime($date_prevprev . " 23:59:59", 'Y-m-d H:i:s'), "!UF_PROG.UF_EPG_SUB_ID" => false);
     $arSelect = array("ID", "SID" => "UF_PROG.UF_EPG_ID", "TITLE" => "UF_PROG.UF_TITLE", "SUB_TITLE" => "UF_PROG.UF_SUB_TITLE", "SERIA" => "UF_PROG.UF_SERIA", "SEASON" => "UF_PROG.UF_SEASON", "UF_DATE_START", "UF_DATE_END");
     $result = \Hawkart\Megatv\ScheduleTable::getList(array('filter' => $arFilter, 'select' => $arSelect));
     while ($arSchedule = $result->fetch()) {
         $arSchedule["UF_DATE_START"] = $arSchedule["DATE_START"] = $arSchedule['UF_DATE_START']->toString();
         $arSchedule["UF_DATE_END"] = $arSchedule["DATE_END"] = $arSchedule['UF_DATE_END']->toString();
         $arSerials[] = $arSchedule;
     }
     /**
      * Get all serials with epg_id
      */
     $arTableSerials = array();
     $result = \Hawkart\Megatv\SerialTable::getList(array('filter' => array("!UF_EPG_ID" => false), 'select' => array("ID", "UF_EPG_ID", "UF_CHANNEL_ID")));
     while ($row = $result->fetch()) {
         $arTableSerials[$row["UF_EPG_ID"]] = $row;
     }
     foreach ($arSerials as $arProg) {
         $title = $arProg["TITLE"];
         if (!empty($arProg["SUB_TITLE"])) {
             $title = $arProg["SUB_TITLE"] . ". " . $title;
         } else {
             if (!empty($arProg["SEASON"])) {
                 $title .= ": сезон " . $arProg["SEASON"];
             }
             if (!empty($arProg["SERIA"])) {
                 $title .= " серия " . $arProg["SERIA"];
             }
         }
         $seria_secs = strtotime($arProg["DATE_END"]) - strtotime($arProg["DATE_START"]);
         $youtube = new \Hawkart\Megatv\Social\YoutubeClient();
         $arVideos = $youtube->search($title);
         $arSerial = $arTableSerials[$arProg["SID"]];
         if (empty($arSerial)) {
             continue;
         }
         //Progs in table by serial_id
         $arTableItems = array();
         $result = \Hawkart\Megatv\ProgExternalTable::getList(array('filter' => array("=UF_SERIAL_ID" => $arSerial["ID"]), 'select' => array("ID", "UF_SERIAL_ID", "UF_EXTERNAL_ID")));
         while ($row = $result->fetch()) {
             $arTableItems[] = $row["UF_EXTERNAL_ID"];
         }
         foreach ($arVideos as $arItem) {
             //secs from youtube
             $time_parts = explode(":", $arItem["TIME"]);
             $secs = 60 * $time_parts[count($time_parts) - 2] + $time_parts[count($time_parts) - 1];
             if (count($time_parts) == 3) {
                 $secs = 60 * intval($time_parts[0]) + intval($time_parts[1]);
             } else {
                 $secs = 3600 * intval($time_parts[0]) + 60 * intval($time_parts[1]) + intval($time_parts[2]);
             }
             $time_perc = $secs / $seria_secs * 100;
             similar_text($title, $arItem["TITLE"], $perc);
             similar_text($arItem["TITLE"], $title, $perc_2);
             if (floatval($perc) < 60 && floatval($perc) >= 40) {
                 $arToFile[] = array("ORIGINAL_TITLE" => $title, "SOCIAL_TITLE" => $arItem["TITLE"], "PERCENT" => $perc, "EXTERNAL_ID" => $arItem["ID"], "TIME" => $arItem["TIME"], "UF_SERIAL_ID" => $arSerial["ID"]);
             }
             if (floatval($perc) > 60 && floatval($perc_2) > 40 && $time_perc > 70) {
                 if (!in_array($arItem["ID"], $arTableItems)) {
                     $datetime = new \Bitrix\Main\Type\DateTime(date("Y-m-d H:i:s", strtotime($arItem["JSON"]["publishedAt"])), 'Y-m-d H:i:s');
                     $arFields = array("UF_TITLE" => $arItem["TITLE"], "UF_EXTERNAL_ID" => $arItem["ID"], "UF_SERIAL_ID" => $arSerial["ID"], "UF_THUMBNAIL_URL" => $arItem["THUMBNAIL_URL"], "UF_VIDEO_URL" => $arItem["VIDEO_URL"], "UF_JSON" => $arItem["JSON"], "UF_DATETIME" => $datetime);
                     $result = \Hawkart\Megatv\ProgExternalTable::add($arFields);
                     if ($result->isSuccess()) {
                         $arTableItems[] = $arItem["ID"];
                     } else {
                         $errors = $result->getErrorMessages();
                     }
                 }
                 break;
             }
         }
     }
     file_put_contents($file_50_60, json_encode($arToFile));
 }
Exemplo n.º 9
0
//Получим все программы текущих каналов за выбранный день
if (!isset($_REQUEST["date"])) {
    $arParams["CURRENT_DATE"] = date("d.m.Y");
} else {
    $arParams["CURRENT_DATE"] = $_REQUEST["date"];
}
$arDate = \CTimeEx::getDateFilter($arParams["CURRENT_DATE"]);
$dateStart = date("Y-m-d H:i:s", strtotime($arDate["DATE_FROM"]));
$dateEnd = date("Y-m-d H:i:s", strtotime($arDate["DATE_TO"]));
$arFilter = array("=UF_CHANNEL_ID" => $arChannelIds, ">=UF_DATE_START" => new \Bitrix\Main\Type\DateTime($dateStart, 'Y-m-d H:i:s'), "<UF_DATE_START" => new \Bitrix\Main\Type\DateTime($dateEnd, 'Y-m-d H:i:s'));
$arSelect = array("ID", "UF_DATE_START", "UF_DATE_END", "UF_DATE", "UF_CHANNEL_ID", "UF_PROG_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_RATING" => "UF_PROG.UF_RATING", "UF_PROG_CODE" => "UF_PROG.UF_CODE");
$obCache = new \CPHPCache();
if ($obCache->InitCache(86400, serialize($arFilter) . serialize($arSelect), "/index-schedules/")) {
    $arResult["DATES"] = $obCache->GetVars();
} elseif ($obCache->StartDataCache()) {
    $result = \Hawkart\Megatv\ScheduleTable::getList(array('filter' => $arFilter, 'select' => $arSelect, 'order' => array("UF_DATE_START" => "ASC")));
    while ($arSchedule = $result->fetch()) {
        $channel = $arSchedule["UF_CHANNEL_ID"];
        $arSchedule["UF_DATE_START"] = $arSchedule["DATE_START"] = \CTimeEx::dateOffset($arSchedule['UF_DATE_START']->toString());
        $arSchedule["UF_DATE_END"] = $arSchedule["DATE_END"] = \CTimeEx::dateOffset($arSchedule['UF_DATE_END']->toString());
        $arSchedule["UF_DATE"] = $arSchedule["DATE"] = substr($arSchedule["DATE_START"], 0, 10);
        $arSchedule["PROG_ID"] = $arSchedule["UF_PROG_ID"];
        $arSchedule["DETAIL_PAGE_URL"] = $arResult["CHANNELS"][$channel]["DETAIL_PAGE_URL"] . $arSchedule["UF_PROG_CODE"] . "/?event=" . $arSchedule["ID"];
        $arResult["DATES"][$arSchedule["UF_DATE"]][$channel][] = $arSchedule;
    }
    $obCache->EndDataCache($arResult["DATES"]);
}
unset($arChannelIds);
/**
 * Create json view for future algorithm
 */
Exemplo n.º 10
0
    $USER = new CUser();
}
$status = false;
$prog_time = intval($_REQUEST["broadcastID"]);
if ($USER->IsAuthorized() && $prog_time > 0) {
    //get subsribe channel list
    $selectedChannels = array();
    $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"];
    }
    $USER_ID = $USER->GetID();
    $rsUser = \CUser::GetByID($USER_ID);
    $arUser = $rsUser->Fetch();
    //get inform about schedule
    $result = \Hawkart\Megatv\ScheduleTable::getList(array('filter' => array("=ID" => $prog_time), 'select' => array("ID", "UF_DATE_START", "UF_DATE_END", "UF_DATE", "UF_CHANNEL_BASE_ID" => "UF_CHANNEL.UF_BASE_ID", "UF_PROG_ID", "UF_CHANNEL_EPG_ID" => "UF_CHANNEL.UF_BASE.UF_EPG_ID", "UF_IMG_PATH" => "UF_PROG.UF_IMG.UF_PATH", "UF_PROG_EPG_ID" => "UF_PROG.UF_EPG_ID", "UF_EPG_ID", "UF_CHANNEL_ID"), 'limit' => 1));
    if ($arSchedule = $result->fetch()) {
        $arSchedule["UF_DATE_START"] = $arSchedule['UF_DATE_START']->toString();
        $arSchedule["UF_DATE_END"] = $arSchedule['UF_DATE_END']->toString();
    }
    //check if schedule in recording yet. Deleted to recordable
    $update = false;
    $result = \Hawkart\Megatv\RecordTable::getList(array('filter' => array("=UF_USER_ID" => $USER_ID, "=UF_SCHEDULE_ID" => $prog_time), 'select' => array("ID", "UF_DELETED"), 'limit' => 1));
    if ($arRecord = $result->fetch()) {
        if (intval($arRecord["UF_DELETED"]) == 1) {
            $update = true;
            $update_id = $arRecord["ID"];
        } else {
            exit(json_encode(array("status" => "error", "error" => "Такая запись уже есть.")));
        }
    }
Exemplo n.º 11
0
              "UF_NAME" => "UF_PROG.UF_TITLE", "UF_SUB_NAME" => "UF_PROG.UF_SUB_TITLE",
          )
      ));
      while ($arSchedule = $result_sh->fetch())
      {   
          if(!in_array($arSchedule["UF_ID"], $ids))
              $html.='<li><a href="http://tvguru.com/channels/'.$arChannel["UF_CODE"].'/'.$arSchedule["UF_ID"].'/">'.trim($arSchedule["UF_NAME"].' '.$arSchedule["UF_SUB_NAME"]).'</a></li>';
          
          $ids[] = $arSchedule["UF_ID"];
      }
      unset($ids);*/
    $html .= "</ul></li>";
}
$urls = array();
$count = 1;
$result = \Hawkart\Megatv\ScheduleTable::getList(array('filter' => array("UF_CHANNEL.UF_BASE.UF_ACTIVE" => 1, "UF_PROG.UF_ACTIVE" => 1), 'select' => array("ID", "UF_ID" => "UF_PROG.UF_EPG_ID", "UF_CHANNEL_CODE" => "UF_CHANNEL.UF_BASE.UF_CODE")));
while ($arSchedule = $result->fetch()) {
    $url = "http://tvguru.com/channels/" . $arSchedule["UF_CHANNEL_CODE"] . "/" . $arSchedule["UF_ID"] . "/";
    $urls[] = $url;
}
$urls = array_unique($urls);
foreach ($urls as $url) {
    $xml .= "<url>\r\n      <loc>" . $url . "</loc>\r\n      <lastmod>" . $date . "</lastmod>\r\n      <changefreq>daily</changefreq>\r\n    </url>";
}
unset($urls);
$xml .= "</urlset>";
$file = $_SERVER["DOCUMENT_ROOT"] . "/sitemap.xml";
file_put_contents($file, $xml);
$html .= '
        </ul></li>
    </ul>