browseType(); } /* browse redirect check */ public static function browseInit() { $p_t = self::browsetype(); $p_t = $p_t == 'broadcasts' ? 'live' : $p_t; $type = $p_t; $rd_to = $type; $_SESSION['q'] = null; $_SESSION['tf'] = null; $_SESSION['uf'] = null; $_SESSION['df'] = null; $_SESSION['ff'] = null; if ($type == '') { $rd_to = ($type == '' and self::$cfg['video_module'] == 1) ? 'video' : (($type == '' and self::$cfg['short_module'] == 1) ? 'short' : (($type == '' and self::$cfg['live_module'] == 1) ? 'live' : (($type == '' and self::$cfg['image_module'] == 1) ? 'image' : (($type == '' and self::$cfg['audio_module'] == 1 ? 'audio' : (($type == '' and self::$cfg['document_module'] == 1 ? 'document' : ($type == '' and self::$cfg['blog_module'] == 1 ? 'blog' : null)))))))); } $guest_for = ($p_t == '' ? $rd_to : $p_t); switch ($guest_for) { case "live":$u = self::$href['broadcasts']; break; case "video":$u = self::$href['videos']; break; case "short":$u = self::$href['shorts']; break; case "image":$u = self::$href['images']; break; case "audio":$u = self::$href['audios']; break; case "doc": case "document":$u = self::$href['documents']; break; case "blog":$u = self::$href['blogs']; break; } $guest_chk = $_SESSION['USER_ID'] == '' ? VHref::guestPermissions('guest_browse_' . ($guest_for == 'document' ? 'doc' : $guest_for), $u) : null; if ($p_t === '' or ($p_t != '' and self::$cfg[$p_t . "_module"] == 0)) { header("Location: " . self::$cfg['main_url']); } return $rd_to; } /* browse files layout */ public static function browseLayout($force_type = false) { if ($force_type) { switch ($force_type) { case self::$href['broadcasts']:self::$type = 'live'; break; case self::$href['videos']:self::$type = 'video'; break; case self::$href['shorts']:self::$type = 'short'; break; case self::$href['images']:self::$type = 'image'; break; case self::$href['audios']:self::$type = 'audio'; break; case self::$href['documents']:self::$type = 'doc'; break; case self::$href['blogs']:self::$type = 'blog'; break; } } $res_promoted = self::$cfg['file_promo'] == 1 ? self::getPromoted() : null; $res_live = self::$type == 'live' ? self::getPromoted(1, 'livenow') : null; $res_media = self::getMedia(); $res_watchlist = self::watchlistEntries(); $html .= self::$type == 'live' ? self::listPromoted($res_live, $res_watchlist, 'livenow') : null; //streams live now $html .= (self::$cfg['file_promo'] == 1 and $res_promoted->fields['file_key']) ? self::listPromoted($res_promoted, $res_watchlist) : null; $html .= self::listMedia($res_media, $res_watchlist); return $html; } /* category file count */ public static function categoryCount($type, $ct_id, $mobile = '', $be = '') { $_u = $_GET['u'] != '' ? sprintf("AND C.`usr_id`='%s'", self::$dbc->singleFieldValue('db_accountuser', 'usr_id', 'usr_key', self::$filter->clr_str(substr($_GET['u'], 1)))) : null; $sql = sprintf("SELECT C.`file_key`, COUNT(*) AS `total` FROM `db_%sfiles` C WHERE C.`file_category` = '%s' %s AND C.`approved` = '1' AND C.`deleted` = '0' AND C.`active` = '1' %s %s;", $type, $ct_id, ($be == '' ? "AND C.`privacy` = 'public'" : null), ($mobile == 1 ? "AND C.`file_mobile`='1'" : null), $_u); $res = self::$db_cache ? self::$db->CacheExecute(self::$cfg['cache_browse_categories_menu'], $sql) : self::$db->execute($sql); return VFiles::numFormat($res->fields['total']); } /* build url from type */ private static function baseUrl() { switch (self::$type[0]) { case "l": $key = 'broadcasts'; break; case "v": $key = 'videos'; break; case "s": $key = 'shorts'; break; case "i": $key = 'images'; break; case "a": $key = 'audios'; break; case "d": $key = 'documents'; break; case "b": $key = 'blogs'; break; } return self::$cfg['main_url'] . '/' . self::$href[$key]; } /* category nav menu */ public static function categoryMenu($type = false, $new_layout = false) { $type = !$type ? self::$type : $type; $get = self::$filter->clr_str($_GET['c']); $sql = sprintf("SELECT `ct_id`, `ct_name`, `ct_lang`, `ct_slug`, `ct_icon` FROM `db_categories` WHERE `ct_type`='%s' AND `sub_id`='0' AND `ct_active`='1' AND `ct_menu`='1' ORDER BY `ct_index` ASC;", $type); $ct = self::$db_cache ? self::$db->CacheExecute(self::$cfg['cache_browse_categories_menu'], $sql) : self::$db->execute($sql); $html = VGenerate::advHTML(13); if ($ct) { if (!$new_layout) { $html .= '

' . self::$language['frontend.global.bestof'] . '

'; } else { $html .= '
#LI_LOOP#
'; } while (!$ct->EOF) { $db_id = $ct->fields['ct_id']; $ct_slug = $ct->fields['ct_slug']; $ct_icon = $ct->fields['ct_icon']; $ct_lang = unserialize($ct->fields['ct_lang']); $ct_src = $_SESSION['fe_lang'] != 'en_US' ? ($ct_lang[$_SESSION['fe_lang']] != '' ? $ct_lang[$_SESSION['fe_lang']] : $ct->fields['ct_name']) : $ct->fields['ct_name']; $ct_name = VUserinfo::truncateString($ct_src, 30); $count = (self::$cfg['file_counts'] == 1 ? ' (' . self::categoryCount($type, $db_id) . ')' : null); $class = $get == $ct_slug ? 'dcjq-parent selected active' : null; $sub_menu = false; $sub_active = array(); $sub_active[$db_id] = ($get === $ct_slug) ? 1 : 0; $sq = self::$db->execute(sprintf("SELECT `ct_name`, `ct_lang`, `ct_slug`, `ct_icon` FROM `db_categories` WHERE `ct_type`='%s' AND `sub_id`='%s' AND `sub_id`>'0' ORDER BY `ct_index` ASC;", $type, $db_id)); if ($sq->fields['ct_slug']) { $lsm = false; $class .= ' sub-categ'; $dsp = 'none'; $dsi = 'xp-down iconBe-chevron-down'; $sub_menu = null; if (!$new_layout) { $sub_menu .= ''; } while (!$sq->EOF) { //$sub_id = $sq->fields['ct_id']; $sub_name = $sq->fields['ct_name']; $sub_lang = unserialize($sq->fields['ct_lang']); $sub_src = $_SESSION['fe_lang'] != 'en_US' ? ($sub_lang[$_SESSION['fe_lang']] != '' ? $sub_lang[$_SESSION['fe_lang']] : $sub_name) : $sub_name; $sub_name = $sub_src; $sub_slug = $sq->fields['ct_slug']; $sub_icon = $sq->fields['ct_icon']; $sub_active[$db_id] = $get === $sub_slug ? 2 : 0; $sub_class = $get === $sub_slug ? 'dcjq-parent-off selected active' : null; if ($sub_active[$db_id] == 2) { $dsp = 'block'; $dsi = 'xp-up iconBe-chevron-up'; } if (!$new_layout) { $sub_menu .= '
  • ' . $sub_name . '
  • '; } else { $sub_menu .= '
    ' . ($sub_icon ? '' : null) . $sub_name . '
    '; } $sq->MoveNext(); } if (!$new_layout) { $sub_menu .= '
  • '; } } if ($sub_menu) { $sub_menu = str_replace('##DSP##', $dsp, $sub_menu); } if (!$new_layout) { $li_loop .= '
  • ' . $ct_name . $count . ' ' . ($sub_menu ? '' . $sub_menu : null) . '
  • '; } else { $li_loop .= '
    ' . $ct_name . $count . '
    '; $li_loop .= $sub_menu ? $sub_menu : null; } @$ct->MoveNext(); } } if (!$new_layout) { $html .= ''; } //this menu $html .= ''; $html .= VGenerate::advHTML(14); return str_replace('#LI_LOOP#', $li_loop, $html); } /* sorting tabs */ private static function tabs() { $html = null; $html .= ' '; if (!self::$new_layout or self::$section == VHref::getKey('channel') or self::$section == VHref::getKey('search')) { $html .= '
    ' . ((isset($_SESSION['q']) and $_SESSION['q'] != '') ? '' : null) . ' ' . (((isset($_SESSION['q']) and $_SESSION['q'] != '' and isset($_GET['tf']) and (int) $_GET['tf'] == 8)) ? '' : null) . ' ' . ((isset($_SESSION['q']) and $_SESSION['q'] != '') ? '' : null) . ' ' . ('') . ' ' . ('') . ' ' . ('') . ' ' . (self::$cfg['file_rating'] == 1 ? '' : null) . ' ' . (self::$cfg['file_comments'] == 1 ? '' : null) . ' ' . (self::$cfg['file_favorites'] == 1 ? '' : null) . ' ' . (self::$cfg['file_responses'] == 1 ? '' : null) . '
    '; } else { $html .= self::$section != VHref::getKey('channel') ? self::categoryMenu(self::$type, true) : null; } return $html; } /* get database entries for promoted */ private static function getPromoted($viewMode_id = null, $for = false) { $type = self::$type; $q = null; $categ_query1 = null; $categ_query2 = null; $categ_query3 = null; $sql_1 = null; $sql_2 = null; $search_order = false; if (isset($_SESSION['q']) and $_SESSION['q'] != '') { $squery = trim($_SESSION['q']); $rel = VGenerate::prepare($squery); $sql_1 = ", MATCH(A.`file_title`) AGAINST ('" . $rel . "') AS `Relevance` "; $sql_2 = "MATCH(A.`file_title`) AGAINST('" . $rel . "' IN BOOLEAN MODE) AND "; $search_order = true; } if (isset($_GET['c'])) { $ct_slug = self::$filter->clr_str($_GET['c']); $categ_query1 = ', E.`ct_name`'; $categ_query2 = ', `db_categories` E'; $categ_query3 = "AND (E.`ct_slug`='" . $ct_slug . "' AND A.`file_category`=E.`ct_id`)"; } switch ($viewMode_id) { default: case "1": $des = null; $lim = self::$promoted_viewMode1_limit; break; case "3": $des = null; $lim = self::$promoted_viewMode2_limit; break; case "2": $des = 'SUBSTRING(A.`file_description`, 1, 200) as `file_description`, '; $lim = self::$promoted_viewMode3_limit; break; } $adr = self::$filter->clr_str($_SERVER['REQUEST_URI']); if (self::$section == self::$href['channel']) { $c = new VChannel; $q .= sprintf(" AND D.`usr_key`='%s' ", VChannel::$user_key); } elseif (isset($_GET['u'])) { $q .= sprintf(" AND D.`usr_key`='%s' ", self::$filter->clr_str($_GET['u'])); } if (isset($_SESSION['uf']) and (int) $_SESSION['uf'] > 0) { //search filter upload date $search_uf = (int) $_SESSION['uf']; switch ($search_uf) { case "1": //last hour $q .= sprintf(" AND A.`upload_date` >= DATE_SUB(NOW(), INTERVAL 1 HOUR) "); break; case "2": //today $q .= sprintf(" AND DATE(A.`upload_date`) = DATE(NOW()) "); break; case "3": //this week $q .= sprintf(" AND YEARWEEK(A.`upload_date`) = YEARWEEK(NOW()) "); break; case "4": //this month $q .= sprintf(" AND A.`upload_date` >= DATE_SUB(NOW(), INTERVAL 1 MONTH) "); break; case "5": //this year $q .= sprintf(" AND YEAR(A.`upload_date`) = YEAR(NOW()) "); break; } } if (isset($_SESSION['df']) and (int) $_SESSION['df'] > 0) { //search filter duration $search_df = (int) $_SESSION['df']; switch ($search_df) { case "1": //short $q .= sprintf(" AND A.`file_duration` < 600 "); break; case "2": //average $q .= sprintf(" AND A.`file_duration` BETWEEN 600 AND 1200 "); break; case "3": //long $q .= sprintf(" AND A.`file_duration` > 1200 "); break; } } if (isset($_SESSION['ff']) and (int) $_SESSION['ff'] > 0) { //search filter features $search_ff = (int) $_SESSION['ff']; switch ($search_ff) { case "1": //sd/static case "4": $q .= sprintf(" AND A.`file_hd` = '0' AND A.`file_type` != 'embed' "); break; case "2": //hd/animated case "5": $q .= sprintf(" AND A.`file_hd` = '1' AND A.`file_type` != 'embed' "); break; case "3": //embedded $q .= sprintf(" AND A.`file_type` = 'embed' "); break; } } $sql = sprintf("SELECT A.`file_key`, A.`file_views`, A.`file_duration`, A.`file_like`, A.`file_comments`, A.`thumb_server`, A.`upload_date`, A.`stream_live`, A.`thumb_preview`, A.`thumb_cache`, A.`file_title`, %s D.`usr_dname`, D.`ch_title`, D.`usr_photo`, D.`usr_profileinc`, D.`usr_partner`, D.`usr_affiliate`, D.`affiliate_badge`, D.`usr_id`, D.`usr_key`, D.`usr_user` %s %s FROM `db_%sfiles` A, `db_accountuser` D %s WHERE %s A.`usr_id`=D.`usr_id` AND " . ($for == 'livenow' ? "A.`stream_live`='1' AND A.`stream_ended`='0' AND" : null) . " " . (!$for ? "A.`is_promoted`='1' AND" : null) . " A.`privacy`='public' AND A.`approved`='1' AND A.`deleted`='0' AND A.`active`='1' %s %s ORDER BY RAND() LIMIT %s", $des, $categ_query1, $sql_1, $type, $categ_query2, $sql_2, $categ_query3, $q, $lim); $res = self::$db_cache ? self::$db->CacheExecute(self::$cfg['cache_browse_promoted'], $sql) : self::$db->execute($sql); return $res; } /* get database entries for short video entries */ public static function getShorts($show = 'latest') { $type = 'short'; $viewMode_id = 1; $sort = self::$filter->clr_str($_GET['sort']); $categ_query1 = null; $categ_query2 = null; $categ_query3 = null; $ct_slug = null; $q = null; $sql_1 = null; $sql_2 = null; $search_order = false; $fshort = []; $fsdb = self::$db->execute(sprintf("SELECT `db_id` FROM `db_shortfiles` WHERE `is_featured`='1' AND `privacy`='public' AND `approved`='1' AND `deleted`='0' AND `active`='1';")); if ($fsdb->fields['db_id']) { while (!$fsdb->EOF) { $fshort[] = $fsdb->fields['db_id']; $fsdb->MoveNext(); } } if (isset($_GET['c'])) { $ct_slug = self::$filter->clr_str($_GET['c']); if ($ct_slug != 'today') { $categ_query1 = ', E.`ct_name`'; $categ_query2 = ', `db_categories` E'; $categ_query3 = "AND (E.`ct_slug`='" . $ct_slug . "' AND A.`file_category`=E.`ct_id`)"; } } $ct_today = $ct_slug === 'today' ? 1 : 0; if ($ct_today == 1) { $q .= sprintf(" AND A.`last_viewdate`='%s' ", date('Y-m-d')); } switch ($viewMode_id) { default: case "1": $des = null; $lim = 8; break; case "3": $des = null; $lim = self::$viewMode2_limit; break; case "2": $des = 'SUBSTRING(A.`file_description`, 1, 200) as `file_description`, '; $lim = self::$viewMode3_limit; break; } switch ($sort) { case "live": $q .= "AND A.`stream_live`='1'"; break; case "recent": $q .= ($type == 'live' ? "AND A.`stream_live`='0' AND A.`stream_ended`='1' " : null) . "ORDER BY A.`db_id` DESC"; break; case "relevance": $q .= "ORDER BY `Relevance` DESC"; break; case "": $q .= $search_order ? "ORDER BY `Relevance` DESC" : ($type == 'live' ? "AND A.`stream_live`='0' AND A.`stream_ended`='1' " : null) . ($show == 'featured' ? "ORDER BY RAND()" : "ORDER BY A.`db_id` DESC"); break; case "featured": $q .= "AND A.`is_featured`='1' ORDER BY RAND()"; break; case "promoted": $q .= "AND A.`is_promoted`='1' ORDER BY RAND()"; break; case "views": $q .= "AND A.`file_views` > '0' ORDER BY A.`file_views` DESC"; break; case "likes": $q .= "AND A.`file_like` > '0' ORDER BY A.`file_like` DESC"; break; case "comments": $q .= "AND A.`file_comments` > '0' ORDER BY A.`file_comments` DESC"; break; case "favorites": $q .= "AND A.`file_favorite` > '0' ORDER BY A.`file_favorite` DESC"; break; case "responses": $q .= "AND A.`file_responses` > '0' ORDER BY A.`file_responses` DESC"; break; } $page = self::$page; $lim_start = $page > 1 ? (($page * $lim) - $lim) : 0; $lim_end = $lim; $lim_sql = sprintf("%s, %s", $lim_start, $lim_end); $showq = (($show == 'latest' and isset($fshort[0])) ? sprintf("A.`db_id` NOT IN (%s) AND", implode(",", $fshort)) : (($show == 'featured' and isset($fshort[0])) ? sprintf("A.`db_id` IN (%s) AND", implode(",", $fshort)) : null)); if ($show == 'featured' and !isset($fshort[0])) { $lim_sql = sprintf("%s, %s", $lim, $lim); } $sql = sprintf("SELECT A.`file_key`, A.`file_views`, A.`file_duration`, A.`file_like`, A.`file_comments`, A.`thumb_server`, A.`upload_date`, A.`embed_src`, A.`stream_live`, A.`thumb_preview`, A.`thumb_cache`, A.`file_title`, %s D.`usr_dname`, D.`ch_title`, D.`usr_partner`, D.`usr_affiliate`, D.`affiliate_badge`, D.`usr_id`, D.`usr_key`, D.`usr_user` %s %s FROM `db_%sfiles` A, `db_accountuser` D %s WHERE %s %s A.`usr_id`=D.`usr_id` AND A.`privacy`='public' AND A.`approved`='1' AND A.`deleted`='0' AND A.`active`='1' %s %s LIMIT %s", $des, $categ_query1, $sql_1, $type, $categ_query2, $sql_2, $showq, $categ_query3, $q, $lim_sql); $res = self::$db_cache ? self::$db->CacheExecute(self::$cfg['cache_browse_main'], $sql) : self::$db->execute($sql); if ($lim_start + $lim >= $total) { self::$page_end = true; } return $res; } /* get database entries for main entries */ private static function getMedia($viewMode_id = null) { $type = self::$type; $sort = self::$filter->clr_str($_GET['sort']); $categ_query1 = null; $categ_query2 = null; $categ_query3 = null; $ct_slug = null; $q = null; $sql_1 = null; $sql_2 = null; $search_order = false; if (isset($_SESSION['q']) and $_SESSION['q'] != '') { $squery = trim($_SESSION['q']); $rel = VGenerate::prepare($squery); $sql_1 = ", MATCH(A.`file_title`) AGAINST ('" . $rel . "') AS `Relevance` "; $sql_2 = "MATCH(A.`file_title`) AGAINST('" . $rel . "' IN BOOLEAN MODE) AND "; $search_order = true; } if (isset($_GET['c'])) { //categories $ct_slug = self::$filter->clr_str($_GET['c']); if ($ct_slug != 'today') { $categ_query1 = ', E.`ct_name`'; $categ_query2 = ', `db_categories` E'; $categ_query3 = "AND (E.`ct_slug`='" . $ct_slug . "' AND A.`file_category`=E.`ct_id`)"; } } $ct_today = $ct_slug === 'today' ? 1 : 0; if ($ct_today == 1) { //today's picks $q .= sprintf(" AND A.`last_viewdate`='%s' ", date('Y-m-d')); } switch ($viewMode_id) { default: case "1": $des = null; $lim = self::$viewMode1_limit; break; case "3": $des = null; $lim = self::$viewMode2_limit; break; case "2": $des = 'SUBSTRING(A.`file_description`, 1, 200) as `file_description`, '; $lim = self::$viewMode3_limit; break; } $adr = self::$filter->clr_str($_SERVER['REQUEST_URI']); if (self::$section == self::$href['channel']) { $c = new VChannel; $q .= sprintf(" AND D.`usr_key`='%s' ", VChannel::$user_key); } elseif (isset($_GET['u'])) { $q .= sprintf(" AND D.`usr_key`='%s' ", self::$filter->clr_str($_GET['u'])); } if (isset($_SESSION['uf']) and (int) $_SESSION['uf'] > 0) { //search filter upload date $search_uf = (int) $_SESSION['uf']; switch ($search_uf) { case "1": //last hour $q .= sprintf(" AND A.`upload_date` >= DATE_SUB(NOW(), INTERVAL 1 HOUR) "); break; case "2": //today $q .= sprintf(" AND DATE(A.`upload_date`) = DATE(NOW()) "); break; case "3": //this week $q .= sprintf(" AND YEARWEEK(A.`upload_date`) = YEARWEEK(NOW()) "); break; case "4": //this month $q .= sprintf(" AND A.`upload_date` >= DATE_SUB(NOW(), INTERVAL 1 MONTH) "); break; case "5": //this year $q .= sprintf(" AND YEAR(A.`upload_date`) = YEAR(NOW()) "); break; } } if (isset($_SESSION['df']) and (int) $_SESSION['df'] > 0) { //search filter duration $search_df = (int) $_SESSION['df']; switch ($search_df) { case "1": //short $q .= sprintf(" AND A.`file_duration` < 600 "); break; case "2": //average $q .= sprintf(" AND A.`file_duration` BETWEEN 600 AND 1200 "); break; case "3": //long $q .= sprintf(" AND A.`file_duration` > 1200 "); break; } } if (isset($_SESSION['ff']) and (int) $_SESSION['ff'] > 0) { //search filter features $search_ff = (int) $_SESSION['ff']; switch ($search_ff) { case "1": //sd/static case "4": $q .= sprintf(" AND A.`file_hd` = '0' AND A.`file_type` != 'embed' "); break; case "2": //hd/animated case "5": $q .= sprintf(" AND A.`file_hd` = '1' AND A.`file_type` != 'embed' "); break; case "3": //embedded $q .= sprintf(" AND A.`file_type` = 'embed' "); break; } } switch ($sort) { case "live": $q .= "AND A.`stream_live`='1'"; break; case "recent": $q .= ($type == 'live' ? "AND A.`stream_live`='0' AND A.`stream_ended`='1' " : null) . "ORDER BY A.`db_id` DESC"; break; case "relevance": $q .= "ORDER BY `Relevance` DESC"; break; case "": //$q .= $search_order ? "ORDER BY `Relevance` DESC" : (self::$section == self::$href['broadcasts'] ? "AND A.`stream_live`='1'" : "ORDER BY A.`db_id` DESC"); $q .= $search_order ? "ORDER BY `Relevance` DESC" : ($type == 'live' ? "AND A.`stream_live`='0' AND A.`stream_ended`='1' " : null) . "ORDER BY A.`db_id` DESC"; break; case "featured": $q .= "AND A.`is_featured`='1' ORDER BY RAND()"; break; case "promoted": $q .= "AND A.`is_promoted`='1' ORDER BY RAND()"; break; case "views": $q .= "AND A.`file_views` > '0' ORDER BY A.`file_views` DESC"; break; case "likes": $q .= "AND A.`file_like` > '0' ORDER BY A.`file_like` DESC"; break; case "comments": $q .= "AND A.`file_comments` > '0' ORDER BY A.`file_comments` DESC"; break; case "favorites": $q .= "AND A.`file_favorite` > '0' ORDER BY A.`file_favorite` DESC"; break; case "responses": $q .= "AND A.`file_responses` > '0' ORDER BY A.`file_responses` DESC"; break; } $page = self::$page; $lim_start = $page > 1 ? (($page * $lim) - $lim) : 0; $lim_end = $lim; $lim_sql = sprintf("%s, %s", $lim_start, $lim_end); $total_sql = sprintf("SELECT COUNT(*) AS `total`, A.`file_key`, D.`usr_id` %s %s FROM `db_%sfiles` A, `db_accountuser` D %s WHERE %s A.`usr_id`=D.`usr_id` AND " . ($type == 'live' ? "A.`stream_ended`='1' AND" : null) . " A.`privacy`='public' AND A.`approved`='1' AND A.`deleted`='0' AND A.`active`='1' %s %s", $categ_query1, $sql_1, $type, $categ_query2, $sql_2, $categ_query3, $q); $total_res = self::$db_cache ? self::$db->CacheExecute(self::$cfg['cache_browse_main'], $total_sql) : self::$db->execute($total_sql); $total = $total_res->fields['total']; $sql = sprintf("SELECT A.`file_key`, A.`file_views`, A.`file_duration`, A.`file_like`, A.`file_comments`, A.`thumb_server`, A.`upload_date`, A.`embed_src`, A.`stream_live`, A.`thumb_preview`, A.`thumb_cache`, A.`file_title`, %s D.`usr_dname`, D.`ch_title`, D.`usr_photo`, D.`usr_profileinc`, D.`usr_partner`, D.`usr_affiliate`, D.`affiliate_badge`, D.`usr_id`, D.`usr_key`, D.`usr_user` %s %s FROM `db_%sfiles` A, `db_accountuser` D %s WHERE %s A.`usr_id`=D.`usr_id` AND " . ($type == 'live-off' ? "A.`stream_ended`='1' AND " : null) . " A.`privacy`='public' AND A.`approved`='1' AND A.`deleted`='0' AND A.`active`='1' %s %s LIMIT %s", $des, $categ_query1, $sql_1, $type, $categ_query2, $sql_2, $categ_query3, $q, $lim_sql); $res = self::$db_cache ? self::$db->CacheExecute(self::$cfg['cache_browse_main'], $sql) : self::$db->execute($sql); if ($lim_start + $lim >= $total) { self::$page_end = true; } return $res; } /* get watchlist entries for logged in user */ public static function watchlistEntries($for = false) { $list = array(); $type = !$for ? self::$type : $for; $uid = (int) $_SESSION['USER_ID']; if (self::$cfg['file_watchlist'] == 1 and $uid > 0) { $sql = sprintf("SELECT `db_id`, `file_key` FROM `db_%swatchlist` WHERE `usr_id`='%s'", $type, $uid); $res = self::$db_cache ? self::$db->CacheExecute(self::$cfg['cache_browse_main'], $sql) : self::$db->execute($sql); if ($res->fields['db_id']) { while (!$res->EOF) { $list[] = $res->fields['file_key']; $res->MoveNext(); } return $list; } } } /* generate thumbnail url location */ public static function thumbnail($usr_key, $file_key, $thumb_server = 0, $nr = 0, $force_type = false) { $thumb_cache = null; $new_key = $usr_key; if (is_array($usr_key)) { $thumb_cache = $usr_key[1]; $thumb_cache = $thumb_cache > 1 ? $thumb_cache : null; $usr_key = $usr_key[0]; } if ($thumb_server > 0) { $expires = 0; $custom_policy = 0; return VGenerate::thumbSigned(($force_type ? $force_type : self::$type), $file_key, $new_key, $expires, $custom_policy, $nr); } return self::$cfg['media_files_url'] . '/' . $usr_key . '/t/' . $file_key . '/' . $nr . $thumb_cache . '.jpg'; } /* grid viewmode */ public static function viewMode1($entries, $user_watchlist, $type = false, $exclude = false) { if ($type) { self::$type = $type; } $dbentries = isset($entries->fields) ? $entries->fields : $entries; if (is_array($dbentries)) { $li_loop = null; $duration_show = (self::$type === 'audio' or self::$type === 'video' or self::$type === 'live') ? 1 : 0; $mobile = VHref::isMobile(); foreach ($entries as $k => $entry) { $dbentries = isset($entries->fields) ? $entries->fields : $entries[$k]; $title = $dbentries['file_title']; $user = $dbentries['usr_user']; $displayname = $dbentries['usr_dname']; $chname = $dbentries['ch_title']; $user = $displayname != '' ? $displayname : ($chname != '' ? $chname : $user); $file_key = $dbentries['file_key']; $usr_key = $dbentries['usr_key']; $usr_id = $dbentries['usr_id']; $usr_affiliate = $dbentries['usr_affiliate']; $usr_partner = $dbentries['usr_partner']; $usr_affiliate = ($usr_affiliate == 1 or $usr_partner == 1) ? 1 : 0; $af_badge = $dbentries['affiliate_badge']; $thumb_server = $dbentries['thumb_server']; $thumb_cache = $dbentries['thumb_cache']; $thumb_cache = $thumb_cache > 1 ? $thumb_cache : null; $usr_photo = $dbentries['usr_photo']; $usr_inc = $dbentries['usr_profileinc']; $is_live = (self::$type == 'live' and $dbentries['stream_live'] == 1) ? true : false; $datetime = VUserinfo::timeRange($dbentries['upload_date']); $duration = VFiles::fileDuration($dbentries['file_duration']); $views = VFiles::numFormat($dbentries['file_views']); $likes = VFiles::numFormat($dbentries['file_like']); $comments = VFiles::numFormat($dbentries['file_comments']); $url = self::$cfg['main_url'] . '/' . VGenerate::fileHref(self::$type[0], $file_key, $title); $user_theme = isset($_SESSION['USER_THEME']) ? $_SESSION['USER_THEME'] : (isset($_SESSION['theme_name']) ? $_SESSION['theme_name'] : self::$cfg['theme_name']); $def_thumb = self::$cfg['global_images_url'] . '/loading-' . (strpos($user_theme, 'dark') !== false ? 'dark' : 'light') . (self::$type == 'short' ? '-shorts' : null) . '.gif'; $vpv = $dbentries['thumb_preview']; $ch_url = VHref::channelURL(["username" => $dbentries['usr_user']]); $ch_img = VUseraccount::getProfileImage_inc($usr_key, $usr_photo, $usr_inc); if ($duration_show == 1 and $duration == '00:00') { $conv = VFileinfo::get_progress($file_key); $conv_class = ' converting'; $thumbnail = '' . $title . ''; } else { $conv = null; $conv_class = null; /* missing folders fix */ if (!is_dir(self::$cfg['media_files_dir'] . '/' . $usr_key . '/t/' . $file_key)) { mkdir(self::$cfg['media_files_dir'] . '/' . $usr_key . '/t/' . $file_key, 0777, true); copy(self::$cfg['global_images_dir'] . '/0.jpg', self::$cfg['media_files_dir'] . '/' . $usr_key . '/t/' . $file_key . '/0' . $thumb_cache . '.jpg'); copy(self::$cfg['global_images_dir'] . '/1.jpg', self::$cfg['media_files_dir'] . '/' . $usr_key . '/t/' . $file_key . '/1' . $thumb_cache . '.jpg'); } $img_tmb = is_file(self::$cfg['media_files_dir'] . '/' . $usr_key . '/t/' . $file_key . '/0' . $thumb_cache . '.jpg'); $img_src = (self::$type == 'blog' and !$img_tmb) ? self::$cfg['global_images_url'] . '/default-blog.png' : self::thumbnail(array($usr_key, $thumb_cache), $file_key, $thumb_server); $thumbnail = '' . $title . ''; } if (self::$cfg['file_watchlist'] == 1) { if (is_array($user_watchlist) and in_array($file_key, $user_watchlist)) { $watchlist_icon = 'icon-check'; $watchlist_text = self::$language['files.menu.watch.in']; $watchlist_info = null; } else { $watchlist_icon = 'icon-clock'; $watchlist_text = self::$language['files.menu.watch.later']; $watchlist_info = ' rel-key="' . $file_key . '" rel-type="' . self::$type . '"'; } } $li_loop .= '
  • ' . (self::$cfg['file_watchlist'] == 1 ? '
    ' . $watchlist_text . '
    ' : null) . '
    ' . ((self::$type == 'video' or self::$type == 'live' or self::$type == 'audio') ? '' : null) . ' ' . $thumbnail . ' ' . (!$mobile ? ' ' : null) . ' ' . ($duration_show == 1 ? '
    ' . ($is_live ? self::$language['frontend.global.live'] : (!$conv ? $duration : null)) . '
    ' . $conv . ' ' : null) . '
    ' . $user . '

    ' . $title . '

    ' . VAffiliate::affiliateBadge($usr_affiliate, $af_badge) . $user . '
    ' . $views . ' ' . ($views == 1 ? self::$language['frontend.global.view'] : self::$language['frontend.global.views']) . ' ' . $datetime . '
  • '; } } if (self::$page > 1) { return $li_loop; } $html = ' '; return $html; } /* list viewmode */ private static function viewMode2($entries, $user_watchlist) { if ($entries->fields['file_key']) { $li_loop = null; $duration_show = (self::$type === 'audio' or self::$type === 'video' or self::$type === 'live') ? 1 : 0; $mobile = VHref::isMobile(); foreach ($entries as $entry) { $title = $entries->fields['file_title']; $description = $entries->fields['file_description']; $user = $entries->fields['usr_user']; $displayname = $entries->fields['usr_dname']; $chname = $entries->fields['ch_title']; $user = $displayname != '' ? $displayname : ($chname != '' ? $chname : $user); $file_key = $entries->fields['file_key']; $usr_key = $entries->fields['usr_key']; $usr_id = $entries->fields['usr_id']; $usr_affiliate = $entries->fields['usr_affiliate']; $usr_partner = $entries->fields['usr_partner']; $usr_affiliate = ($usr_affiliate == 1 or $usr_partner == 1) ? 1 : 0; $af_badge = $entries->fields['affiliate_badge']; $thumb_server = $entries->fields['thumb_server']; $thumb_cache = $entries->fields['thumb_cache']; $thumb_cache = $thumb_cache > 1 ? $thumb_cache : null; $usr_photo = $entries->fields['usr_photo']; $usr_inc = $entries->fields['usr_profileinc']; $is_live = (self::$type == 'live' and $entries->fields['stream_live'] == 1) ? true : false; $datetime = VUserinfo::timeRange($entries->fields['upload_date']); $duration = VFiles::fileDuration($entries->fields['file_duration']); $views = VFiles::numFormat($entries->fields['file_views']); $likes = VFiles::numFormat($entries->fields['file_like']); $comments = VFiles::numFormat($entries->fields['file_comments']); $url = self::$cfg['main_url'] . '/' . VGenerate::fileHref(self::$type[0], $file_key, $title); $ch_url = VHref::channelURL(["username" => $entries->fields['usr_user']]); $user_theme = isset($_SESSION['USER_THEME']) ? $_SESSION['USER_THEME'] : (isset($_SESSION['theme_name']) ? $_SESSION['theme_name'] : self::$cfg['theme_name']); $def_thumb = self::$cfg['global_images_url'] . '/loading-' . (strpos($user_theme, 'dark') !== false ? 'dark' : 'light') . (self::$type == 'short' ? '-shorts' : null) . '.gif'; $vpv = $entries->fields['thumb_preview']; $ch_img = VUseraccount::getProfileImage_inc($usr_key, $usr_photo, $usr_inc); if ($duration_show == 1 and $duration == '00:00') { $conv = VFileinfo::get_progress($file_key); $conv_class = ' converting'; $thumbnail = '' . $title . ''; } else { $conv = null; $conv_class = null; $img_tmb = is_file(self::$cfg['media_files_dir'] . '/' . $usr_key . '/t/' . $file_key . '/0' . $thumb_cache . '.jpg'); $img_src = (self::$type == 'blog' and !$img_tmb) ? self::$cfg['global_images_url'] . '/default-blog.png' : self::thumbnail(array($usr_key, $thumb_cache), $file_key, $thumb_server); $thumbnail = '' . $title . ''; } if (self::$cfg['file_watchlist'] == 1) { if (is_array($user_watchlist) and in_array($file_key, $user_watchlist)) { $watchlist_icon = 'icon-check'; $watchlist_text = self::$language['files.menu.watch.in']; $watchlist_info = null; } else { $watchlist_icon = 'icon-clock'; $watchlist_text = self::$language['files.menu.watch.later']; $watchlist_info = ' rel-key="' . $file_key . '" rel-type="' . self::$type . '"'; } } $li_loop .= '
  • ' . (self::$cfg['file_watchlist'] == 1 ? '
    ' . $watchlist_text . '
    ' : null) . '
    ' . ((self::$type == 'video' or self::$type == 'live' or self::$type == 'audio') ? '' : null) . ' ' . $thumbnail . ' ' . ($duration_show == 1 ? '
    ' . ($is_live ? self::$language['frontend.global.live'] : (!$conv ? $duration : null)) . '
    ' . $conv . ' ' : null) . ' ' . (!$mobile ? ' ' : null) . '

    ' . $title . '

    ' . nl2br($description) . '

    ' . $user . '
    ' . VAffiliate::affiliateBadge($usr_affiliate, $af_badge) . $user . '
    ' . $views . ' ' . ($views == 1 ? self::$language['frontend.global.view'] : self::$language['frontend.global.views']) . ' ' . $datetime . '
  • '; } } if (self::$page > 1) { return $li_loop; } $html = ' '; return $html; } /* viewmode loader */ public static function viewMode_loader($viewMode_id, $entries = false, $user_watchlist = false) { $entries = !$entries ? (isset($_GET['p']) and (int) $_GET['p'] == 1) ? self::getPromoted($viewMode_id) : self::getMedia($viewMode_id) : $entries; $section = $entries ? (isset($_GET['sort']) ? self::$filter->clr_str($_GET['sort']) : ((isset($_SESSION['q']) and $_SESSION['q'] != '') ? 'relevance' : 'recent')) : false; if (!$section) { return; } if (!$user_watchlist) { $user_watchlist = self::watchlistEntries(); } $method = "viewMode" . $viewMode_id; $content = $entries->fields['file_key'] ? self::$method($entries, $user_watchlist) : VGenerate::simpleDivWrap('no-content', '', self::$language['frontend.global.results.none']); if (self::$page_end) { if (isset($_GET['m'])) { $js = 'if (typeof($) != "undefined") { setTimeout(function () { $("#main-view-mode-' . $viewMode_id . '-' . $section . '-more").detach(); }, 200); }'; $content .= VGenerate::declareJS('$(document).ready(function(){' . $js . '});'); } } else { $content .= ((isset($_GET['p']) and (int) $_GET['p'] == 0 and !isset($_GET['page'])) or !isset($_GET['p'])) ? self::loadMore($viewMode_id, $section) : null; } return $content; } /* tab section loader */ public static function tabSection_loader($tabSection, $category = false) { // $default_viewMode = (int) $_SESSION[self::$type."_vm"] > 0 ? (int) $_SESSION[self::$type."_vm"] : 1; $default_viewMode = 1; $title_category = $category ? ' ' . $category : null; switch ($tabSection) { case "recent": $title = self::typeLangReplace(self::$language['files.menu.recent.type']); $icon = 'clock-o'; break; case "live": $title = self::typeLangReplace(self::$language['files.menu.live.type']); $icon = 'live'; break; case "relevance": $title = self::typeLangReplace(self::$language['files.menu.relavant.type']); $icon = 'search'; break; case "featured": $title = self::typeLangReplace(self::$language['files.menu.featured.type']); $icon = 'star'; break; case "promoted": $title = self::typeLangReplace(self::$language['files.menu.promoted.type']); $icon = 'bullhorn'; break; case "views": $title = self::typeLangReplace(self::$language['files.menu.viewed.type']); $icon = 'eye'; break; case "likes": $title = self::typeLangReplace(self::$language['files.menu.most.liked.type']); $icon = 'thumbs-up'; break; case "comments": $title = self::typeLangReplace(self::$language['files.menu.commented.type']); $icon = 'comment'; break; case "favorites": $title = self::typeLangReplace(self::$language['files.menu.favorited.type']); $icon = 'heart'; break; case "responses": $title = self::typeLangReplace(self::$language['files.menu.responded.type']); $icon = 'comments'; break; } $html = '
    ' . self::filter_dl_menu($tabSection) . '
    '; return $html; } /* list promoted entries */ private static function listPromoted($entries, $user_watchlist, $livenow = false) { $category = isset($entries->fields['ct_name']) ? $entries->fields['ct_name'] : false; $title_category = $category ? ' ' . $category : null; $default_viewMode = (int) $_SESSION[self::$type . "_pvm"] > 0 ? (int) $_SESSION[self::$type . "_pvm"] : 1; $default_viewMode = 1; $fn = 'viewMode' . $default_viewMode; $content = $entries->fields['file_key'] ? self::$fn($entries, $user_watchlist) : (!$livenow ? VGenerate::simpleDivWrap('no-content', '', self::$language['frontend.global.results.none']) : false); if ($content !== false) { $html = '

    ' . ($livenow ? self::$language['frontend.global.live.now'] : self::typeLangReplace(self::$language['frontend.global.promoted'])) . $title_category . '

    ' . (!$livenow ? '
    ' : null) . '
    ' . VGenerate::advHTML(56) . ' ' . VGenerate::advHTML(57) . '
    '; } return $html; } private static function filter_dl_menu($default_section) { if (self::$section == VHref::getKey('search')) { return; } if (self::$section == VHref::getKey('channel')) { return $html = ' '; } $html = null; $html = ' '; return $html; } /* list available media files */ private static function listMedia($entries, $user_watchlist) { $category = isset($entries->fields['ct_name']) ? $entries->fields['ct_name'] : false; $title_category = $category ? ' ' . $category : null; $default_viewMode = (int) $_SESSION[self::$type . "_vm"] > 0 ? (int) $_SESSION[self::$type . "_vm"] : 1; $default_viewMode = 1; $content = $entries->fields['file_key'] ? self::viewMode_loader($default_viewMode, $entries, $user_watchlist) : VGenerate::simpleDivWrap('no-content', '', self::$language['frontend.global.results.none']); //$default_section= (isset($_SESSION['q']) and $_SESSION['q'] != '') ? 'relevance' : (self::$section == self::$href['broadcasts'] ? 'live' : 'recent'); $default_section = (isset($_SESSION['q']) and $_SESSION['q'] != '') ? 'relevance' : 'recent'; $html = '
    ' . self::tabs() . '
    ' . self::filter_dl_menu($default_section) . '
    ' . VGenerate::advHTML(58) . ' ' . VGenerate::advHTML(59) . '
    ' . ((isset($_SESSION['q']) and $_SESSION['q'] != '' and (isset($_GET['tf']) and (int) $_GET['tf'] == 8)) ? self::tabSection_loader('live', $category) : null) . ' ' . ((isset($_SESSION['q']) and $_SESSION['q'] != '') ? self::tabSection_loader('promoted', $category) : null) . ' ' . (((isset($_SESSION['q']) and $_SESSION['q'] != '') or self::$section == self::$href['broadcasts-off']) ? self::tabSection_loader('recent', $category) : null) . ' ' . self::tabSection_loader('featured', $category) . ' ' . self::tabSection_loader('views', $category) . ' ' . self::tabSection_loader('likes', $category) . ' ' . self::tabSection_loader('comments', $category) . ' ' . self::tabSection_loader('favorites', $category) . ' ' . self::tabSection_loader('responses', $category) . '
    '; return $html; } private static function loadMore($viewMode, $section) { $html = '
    '; return $html; } private static function typeLangReplace($src) { return str_replace('##TYPE##', self::$language["frontend.global." . self::$type[0] . ".p.c"], $src); } }