Example #1
0
 public function indexAction()
 {
     //Check whether the cache with key "downloads" exists or has expired
     if ($this->view->getCache()->exists('downloads')) {
         //Query the latest downloads
         $latest = Downloads::find(array('order' => 'created_at DESC'));
         $this->view->setVar('latest', $latest);
     }
     //Enable the cache with the same key "downloads"
     $this->view->cache(array('key' => 'downloads'));
 }
 private function getLinkByRecId($rec_id)
 {
     $item = self::getById($rec_id);
     $master = new StreamRecorder();
     try {
         $res = $master->play($rec_id, 0, false, $item['storage_name']);
     } catch (Exception $e) {
         trigger_error($e->getMessage());
     }
     $res['local'] = 0;
     if (!empty($res['cmd'])) {
         preg_match("/\\.(\\w*)\$/", $res['cmd'], $ext_arr);
         $res['to_file'] = System::transliterate($item['id'] . '_' . Itv::getChannelNameById($item['ch_id']) . '_' . $item['program']);
         $res['to_file'] .= '.' . $ext_arr[1];
     }
     if (!empty($_REQUEST['download'])) {
         $downloads = new Downloads();
         $res['cmd'] = $downloads->createDownloadLink('pvr', $rec_id, Stb::getInstance()->id);
     }
     return $res;
 }
Example #3
0
 public function createLink()
 {
     preg_match("/\\/media\\/(\\d+).mpg(.*)/", $_REQUEST['cmd'], $tmp_arr);
     $media_id = $tmp_arr[1];
     $params = $tmp_arr[2];
     $forced_storage = $_REQUEST['forced_storage'];
     $disable_ad = $_REQUEST['disable_ad'];
     $link = $this->getLinkByVideoId($media_id, intval($_REQUEST['series']), $forced_storage);
     if ($_REQUEST['download']) {
         if (preg_match('/\\.(\\w*)$/', $link['cmd'], $match)) {
             $extension = $match[1];
         }
         $downloads = new Downloads();
         $link['cmd'] = $downloads->createDownloadLink('vclub', $media_id, Stb::getInstance()->id, intval($_REQUEST['series'])) . (isset($extension) ? '&ext=.' . $extension : '');
     } else {
         $link['cmd'] = $link['cmd'] . $params;
     }
     if (Config::get('enable_tariff_plans')) {
         $user = User::getInstance(Stb::getInstance()->id);
         $options = $user->getServicesByType('option');
         if ($options && array_search('disable_vclub_ad', $options) !== false) {
             $disable_ad = true;
         }
     }
     $moderator = $this->db->from('moderators')->where(array('mac' => Stb::getInstance()->mac))->use_caching()->get()->first();
     if (!$disable_ad) {
         $disable_ad = !empty($moderator) && $moderator['status'] == 1 && $moderator['disable_vclub_ad'] == 1 || !empty($_REQUEST['download']);
     }
     $vclub_ad = new VclubAdvertising();
     if (!$disable_ad && empty($link['error'])) {
         $video = Video::getById($media_id);
         $picked_ad = $vclub_ad->getOneWeightedRandom($video['category_id']);
         if (!empty($picked_ad)) {
             $link['cmd'] = $_REQUEST['cmd'];
             $link = array(array('id' => 0, 'ad_id' => $picked_ad['id'], 'ad_must_watch' => $picked_ad['must_watch'], 'type' => 'ad', 'cmd' => $picked_ad['url']), $link);
         }
     }
     var_dump($link);
     return $link;
 }
Example #4
0
* 下载分类编辑
* php>=5.0
* @author LEI
* @version 1.1.2
* @time 20111004
*/
//初始化
$pagetitle = '下载分类编辑';
$pagepower = 'downloads_class';
$moduleRoot = WEB_MODULE . 'downloads/';
//基本部分
require WEB_INC . WEB_APP . 'controller/' . 'checkpower.inc.php';
//功能部分
include $moduleRoot . 'model/' . 'downloads.class.php';
include $moduleRoot . 'model/' . 'downloads_class.class.php';
$downloads = new Downloads();
$downloads_class = new Downloads_class();
require_once WEB_INC . 'uclass.class.php';
$CL = new Uclass();
switch ($a) {
    case 'list':
    default:
        //list
        $List = $downloads_class->GetList(array('id', 'rootid', 'title', 'parentid'));
        $List = $CL->arraySet($List, 0);
        if (is_file(WEB_TPL . 'downloads_class_list.tpl.php')) {
            $templatefile = 'downloads_class_list.tpl.php';
        } else {
            $tpl_in_module = 1;
            $templatefile = $moduleRoot . WEB_APP . 'templates/' . 'downloads_class_list.tpl.php';
        }
 /**
  * Return link for program
  *
  * @return array
  */
 public function createLink()
 {
     $res = array('id' => 0, 'cmd' => '', 'storage_id' => '', 'load' => '0', 'error' => '');
     preg_match("/\\/media\\/(\\d+).mpg/", $_REQUEST['cmd'], $tmp_arr);
     $program_id = $tmp_arr[1];
     $program = Epg::getById($program_id);
     try {
         $task = $this->getLessLoadedTaskByChId($program['ch_id']);
     } catch (StorageSessionLimitException $e) {
         $res['error'] = 'limit';
         $res['storage_name'] = $e->getStorageName();
         return $res;
     }
     $overlap = Config::getSafe('tv_archive_playback_overlap', 0) * 60;
     $overlap_start = Config::getSafe('tv_archive_playback_overlap_start', 0) * 60;
     $tz = new DateTimeZone(Stb::$server_timezone);
     $date = new DateTime(date('r', strtotime($program['time'])));
     $date->setTimeZone($tz);
     if ($overlap_start) {
         $date->sub(new DateInterval('PT' . $overlap_start . 'S'));
     }
     $date_now = new DateTime('now', new DateTimeZone(Stb::$server_timezone));
     $date_to = new DateTime(date('r', strtotime($program['time_to'])));
     $date_to->setTimeZone($tz);
     $dst_diff = $date->format('Z') - $date_now->format('Z');
     $storage = Master::getStorageByName($task['storage_name']);
     if (!$storage['flussonic_dvr'] && !$storage['wowza_dvr']) {
         if ($dst_diff > 0) {
             $date->add(new DateInterval('PT' . $dst_diff . 'S'));
             $date_to->add(new DateInterval('PT' . $dst_diff . 'S'));
         } elseif ($dst_diff < 0) {
             $dst_diff *= -1;
             $date->sub(new DateInterval('PT' . $dst_diff . 'S'));
             $date_to->sub(new DateInterval('PT' . $dst_diff . 'S'));
         }
     }
     $start_timestamp = $date->getTimestamp();
     $stop_timestamp = $date_to->getTimestamp() + $overlap;
     $channel = Itv::getChannelById($program['ch_id']);
     $filename = $date->format("Ymd-H");
     if ($channel['wowza_dvr']) {
         $filename .= '.mp4';
     } else {
         $filename .= '.mpg';
     }
     $res['storage_id'] = $storage['id'];
     $position = date("i", $start_timestamp) * 60 + date("s", $start_timestamp);
     if ($storage['flussonic_dvr']) {
         if (preg_match("/:\\/\\/([^\\/]*)\\/([^\\/]*).*(mpegts|m3u8)\$/", $channel['mc_cmd'], $match)) {
             if ($match[3] == 'mpegts') {
                 $res['cmd'] = 'http://' . $storage['storage_ip'] . '/' . $match[2] . '/archive/' . $start_timestamp . '/' . ($stop_timestamp - $start_timestamp) . '/mpegts';
             } else {
                 $res['cmd'] = preg_replace('/:\\/\\/([^\\/]*)/', '://' . $storage['storage_ip'], $channel['mc_cmd']);
                 $res['cmd'] = preg_replace('/\\.m3u8/', '-' . $start_timestamp . '-' . ($stop_timestamp - $start_timestamp) . '.m3u8', $res['cmd']);
             }
             $res['cmd'] .= '?ch_id=' . $program['ch_id'] . '&token=' . $this->createTemporaryToken($this->stb->id) . '&start=' . $position . '&duration=' . ($stop_timestamp - $start_timestamp) . '&osd_title=' . urlencode($channel['name'] . ' — ' . $program['name']) . '&real_id=' . $program['real_id'];
             $res['download_cmd'] = 'http://' . $storage['storage_ip'] . '/' . $match[2] . '/archive-' . $start_timestamp . '-' . ($stop_timestamp - $start_timestamp) . '.ts';
         } else {
             $res['error'] = 'link_fault';
         }
     } elseif ($storage['wowza_dvr']) {
         if (preg_match("/:\\/\\/([^\\/]*)\\/.*\\.m3u8/", $channel['mc_cmd'], $match)) {
             $res['cmd'] = preg_replace('/:\\/\\/([^\\/]*)/', '://' . $storage['storage_ip'], $channel['mc_cmd']);
             $res['cmd'] = preg_replace('/\\.m3u8.*/', '.m3u8?DVR&wowzadvrplayliststart=' . gmdate("YmdHis", $start_timestamp) . '&wowzadvrplaylistduration=' . ($stop_timestamp - $start_timestamp) * 1000, $res['cmd']) . '&ch_id=' . $program['ch_id'] . '&token=' . $this->createTemporaryToken("1") . '&start=' . $position . '&duration=' . ($stop_timestamp - $start_timestamp) . '&osd_title=' . urlencode($channel['name'] . ' — ' . $program['name']) . '&real_id=' . $program['real_id'];
             $res['download_cmd'] = false;
         } else {
             $res['error'] = 'link_fault';
         }
     } else {
         $res['cmd'] = Config::getSafe('tv_archive_player_solution', 'ffmpeg') . ' http://' . $storage['storage_ip'] . ':' . $storage['apache_port'] . '/stalker_portal/storage/get.php?filename=' . $filename . '&ch_id=' . $program['ch_id'] . '&token=' . $this->createTemporaryToken(true) . '&start=' . $position . '&duration=' . ($stop_timestamp - $start_timestamp) . '&osd_title=' . urlencode($channel['name'] . ' — ' . $program['name']) . '&real_id=' . $program['real_id'];
         if (!empty($_REQUEST['download'])) {
             $downloads = new Downloads();
             $res['download_cmd'] = $downloads->createDownloadLink('tv_archive', $program_id, Stb::getInstance()->id);
         } else {
             $res['download_cmd'] = false;
         }
     }
     $res['to_file'] = date("Ymd-H", $start_timestamp) . '_' . System::transliterate($channel['name'] . '_' . $program['name']) . '.mpg';
     var_dump($res);
     return $res;
 }
 /**
  * Add file download record
  * 
  * @param int $file_id File Id
  */
 private function add_download_record($file_id)
 {
     $downloads = new Downloads();
     $downloads->add($file_id);
 }
session_start();
require_once "header.php";
$failedGoTo = "home.php";
$successGoTo = "downloads.php";
$logoutGoTo = "home.php";
$access = new Access();
$logonUser = $access->isInitAccess();
if ($logonUser) {
    $typeUser = $access->isAdminUser();
}
$access->processLogout($logoutGoTo);
$access->processLogonRestriction($failedGoTo);
$access->processSendAccess($successGoTo, $failedGoTo);
unset($access);
$downloads = new Downloads();
$cuntryArray = $downloads->getCountrys();
//unset($collections);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><!-- InstanceBegin template="/Templates/Main.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- InstanceBeginEditable name="doctitle" -->
<title>CIP (Collector and Injection Panel)</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<?php 
?>
<!-- InstanceEndEditable -->
<style type="text/css">
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getDownloads()
 {
     return $this->hasMany(Downloads::className(), ['uid' => 'id']);
 }
Example #9
0
/**
 * PHPB2B :  Opensource B2B Script (http://www.phpb2b.com/)
 * Copyright (C) 2007-2010, Ualink. All Rights Reserved.
 * 
 * Licensed under The Languages Packages Licenses.
 * Support : phpb2b@hotmail.com
 * 
 * @version $Revision: 1393 $
 */
require "../libraries/common.inc.php";
uses("Download");
require APP_ROOT . './libraries/page.class.php';
require "session_cp.inc.php";
include CACHE_PATH . "cache_typeoption.php";
$download = new Downloads();
$conditions = null;
$tpl_file = "download";
$joins = array();
$page = new Pages();
if (isset($_GET['do'])) {
    $do = trim($_GET['do']);
    if (!empty($_GET['id'])) {
        $id = intval($_GET['id']);
    }
    if ($do == "edit") {
        if ($id) {
            setvar("item", $keyword->read("*", $id));
        }
        //$tpl_file = "keyword.edit";
        //	template($tpl_file);
Example #10
0
     }
     if ($status != 1) {
         flash("Bạn chưa thanh toán thành công, nên không thể tải game về máy", "content.php?id=" . $pid, 10);
     }
     uses("attachment");
     $attachment = new Attachments();
     if (empty($_GET['aid'])) {
         flash();
     }
     $attach_id = authcode(rawurldecode($_GET['aid']), "DECODE");
     if (empty($attach_id)) {
         flash("File game không tồn tại trên hệ thống!");
     }
     require LIB_PATH . "download.class.php";
     require LIB_PATH . "js.class.php";
     $download = new Downloads('', false);
     $download->attach_filename = rawurlencode($attachment->getAttachFileName($attach_id));
     $filename = "../" . $attachment->file_url;
     if (!$download->downloadfile($filename)) {
         die($download->geterrormsg());
     } else {
         JS::Close();
     }
     break;
 case "charging":
     //Băt đầu charging
     if ($info['iffree'] != 1) {
         if (empty($_SESSION['msisdn'])) {
             flash("Hiện tại hệ thống chưa nhận diện được số thuê bao, nên không thể thanh toán hãy liên hệ với quản trị để biết thông tin chi tiết!", "content.php?id=" . $pid, 10);
         }
         if (isset($_GET['pid'])) {
Example #11
0
* ZCNCMS
* 下载
* php>=5.0
* @author LEI
* @version 1.1.2
* @time 20111004
*/
//初始化
$pagetitle = '下载';
$topTitle = '';
$where = '';
$moduleRoot = WEB_ROOT . 'module/downloads/';
//功能部分
include $moduleRoot . 'model/' . 'downloads.class.php';
include $moduleRoot . 'model/' . 'downloads_class.class.php';
$downloads = new Downloads();
$downloads_class = new Downloads_class();
include WEB_MOD . 'ads.class.php';
include WEB_MOD . 'adflash.class.php';
$ads = new Ads();
$adflash = new Adflash();
include WEB_MOD . 'keys.class.php';
$keys = new Keys();
include WEB_INC . 'validator.class.php';
$v = new Validator();
include WEB_MOD . 'links.class.php';
$links = new Links();
$templatefile = '';
$classinfo = '';
//
//classid
Example #12
0
/**
 * PHPB2B :  Opensource B2B Script (http://www.phpb2b.com/)
 * Copyright (C) 2007-2010, Ualink. All Rights Reserved.
 * 
 * Licensed under The Languages Packages Licenses.
 * Support : phpb2b@hotmail.com
 * 
 * @version $Revision: 1393 $
 */
require "../libraries/common.inc.php";
uses("Download");
require APP_ROOT . './libraries/page.class.php';
require "session_cp.inc.php";
include CACHE_PATH . "cache_typeoption.php";
$page = new Pages();
$download = new Downloads();
$conditions = null;
$tpl_file = "download.detail";
$joins = array();
$today = getdate();
//$fromdate = date("Y-m-d",strtotime("-24 hours"));
//$todate = date("Y-m-d");
$fromdate = date("Y-m-d");
$todate = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') + 1, date('Y')));
setvar("fromdate", $fromdate);
setvar("todate", $todate);
$condition = "create_on BETWEEN ";
$condition .= "'" . $fromdate . "'";
$condition .= " AND ";
$condition .= "'" . $todate . "'";
$conditions[] = $condition;
Example #13
0
* php>=5.0
* @author LEI
* @version 1.1.2
* @time 20111004
*/
//初始化
$pagetitle = '下载编辑';
$pagepower = 'downloads';
$where = '';
$moduleRoot = WEB_MODULE . 'downloads/';
//基本部分
require WEB_INC . WEB_APP . 'controller/' . 'checkpower.inc.php';
//功能部分
include $moduleRoot . 'model/' . 'downloads.class.php';
include $moduleRoot . 'model/' . 'downloads_class.class.php';
$downloads = new Downloads();
$downloads_class = new Downloads_class();
require_once WEB_INC . 'uclass.class.php';
$CL = new Uclass();
switch ($a) {
    case 'list':
    default:
        //list
        //列表
        if (empty($classid)) {
            $where = ' 1 = 1 ';
        } else {
            $where = " classid = '" . $classid . "' ";
        }
        $pageListNum = 12;
        //每页显示