clr_str($_GET["s"]) : null; self::$section = isset($_GET["pp"]) ? $href["playlists"] : $section; self::$page = isset($_GET["page"]) ? (int) $_GET["page"] : 1; self::$page_end = false; self::$page_links = null; self::$smarty = $smarty; $_type = self::browseType(); self::$type = $_type == 'document' ? 'doc' : $_type; self::$db_cache = false; //change here to enable caching } /* browse type */ public static function browseType() { if (isset($_GET["s"]) and strlen($_GET["s"]) > 16) { $_s = self::$filter->clr_str($_GET["s"]); if (strlen($_s) > 16 and substr($_s, 0, 16) == 'file-menu-entry6') { $_r = str_replace('file-menu-entry6-sub', '', $_s); switch ($_r[0]) { case "l":return 'live'; case "v":return 'video'; case "s":return 'short'; case "i":return 'image'; case "a":return 'audio'; case "d":return 'doc'; case "b":return 'blog'; } } } $adr = self::$filter->clr_str($_SERVER["REQUEST_URI"]); if (self::$section == self::$href["blogs"] or (self::$section == self::$href["search"] and (int) $_GET["tf"] == 7) or (self::$section == self::$href["channel"] and strpos($adr, self::$href["blogs"]) !== false)) { return 'blog'; } return isset($_GET["t"]) ? self::$filter->clr_str($_GET["t"]) : (isset($_GET["s"]) ? 'short' : (isset($_GET["l"]) ? 'live' : (isset($_GET["v"]) ? 'video' : (isset($_GET["i"]) ? 'image' : (isset($_GET["a"]) ? 'audio' : (isset($_GET["d"]) ? 'doc' : (isset($_GET['b']) ? 'blog' : 'video'))))))); } /* browse redirect check */ public static function browseInit() { $p_t = self::browsetype(); $type = $p_t; $rd_to = $type; if ($type == '') { $rd_to = (($type == '' and self::$cfg["live_module"] == 1) ? 'live' : (($type == '' and self::$cfg["video_module"] == 1) ? 'video' : (($type == '' and self::$cfg["short_module"] == 1) ? 'short' : (($type == '' and self::$cfg["image_module"] == 1) ? 'image' : (($type == '' and self::$cfg["audio_module"] == 1 ? 'audio' : (($type == '' and self::$cfg["document_module"] == 1 ? 'document' : null)))))))); } $guest_for = ($p_t == '' ? $rd_to : $p_t); $guest_chk = $_SESSION["USER_ID"] == '' ? VHref::guestPermissions('guest_browse_' . ($guest_for == 'document' ? 'doc' : $guest_for), VHref::getKey("browse") . '?t=' . $guest_for) : null; if ($p_t === '' or ($p_t != '' and self::$cfg[$p_t . "_module"] == 0)) { header("Location: " . self::$cfg["main_url"] . '/' . VHref::getKey("browse") . '?t=' . $rd_to); } return $rd_to; } /* browse files layout */ public static function browseLayout() { global $section; $res_media = self::getMedia(); $res_watchlist = self::watchlistEntries(); $html .= self::typeFilters(); $html .= '
'; $html .= self::$cfg["video_module"] == 1 ? self::listMedia((self::$type == 'video' ? $res_media : []), (self::$type == 'video' ? $res_watchlist : []), 'video', (self::$type !== 'video')) : null; $html .= self::$cfg["short_module"] == 1 ? self::listMedia((self::$type == 'short' ? $res_media : []), (self::$type == 'short' ? $res_watchlist : []), 'short', (self::$type !== 'short')) : null; $html .= self::$cfg["live_module"] == 1 ? self::listMedia((self::$type == 'live' ? $res_media : []), (self::$type == 'live' ? $res_watchlist : []), 'live', (self::$type !== 'live')) : null; $html .= self::$cfg["image_module"] == 1 ? self::listMedia((self::$type == 'image' ? $res_media : []), (self::$type == 'image' ? $res_watchlist : []), 'image', (self::$type !== 'image')) : null; $html .= self::$cfg["audio_module"] == 1 ? self::listMedia((self::$type == 'audio' ? $res_media : []), (self::$type == 'audio' ? $res_watchlist : []), 'audio', (self::$type !== 'audio')) : null; $html .= self::$cfg["document_module"] == 1 ? self::listMedia((self::$type == 'doc' ? $res_media : []), (self::$type == 'doc' ? $res_watchlist : []), 'doc', (self::$type !== 'doc')) : null; $html .= self::$cfg["blog_module"] == 1 ? self::listMedia((self::$type == 'blog' ? $res_media : []), (self::$type == 'blog' ? $res_watchlist : []), 'blog', (self::$type !== 'blog')) : null; $html .= '
'; $html .= ' '; return $html; } /* file key checking */ public function fileKeyCheck($type, $key, $return = '') { $sql = sprintf("SELECT `usr_id`, `privacy`, `approved` FROM `db_%sfiles` WHERE `file_key`='%s' AND `active`='1' AND `deleted`='0' LIMIT 1;", $type, $key); $f_rs = self::$db_cache ? self::$db->CacheExecute(self::$cfg['cache_key_check'], $sql) : self::$db->execute($sql); $f_uid = $f_rs->fields["usr_id"]; $f_pr = $f_rs->fields["privacy"]; $f_app = $f_rs->fields["approved"]; $uid = (int) $_SESSION["USER_ID"]; if ($f_app == 1 or ($f_app == 0 and $f_uid == $uid)) { if ($f_pr == 'public' or ($f_pr == 'private' and $f_uid == $uid) or ($f_pr == 'personal' and $f_uid == $uid)) { if ($return == 1) { return 1; } $q .= "(A.`file_key` = '" . $key . "' AND A.`privacy`='public' AND A.`approved`='1') OR "; } elseif ($f_pr == 'private' and $f_uid != $uid) { $bl_stat = VContacts::getBlockStatus($f_uid, $_SESSION["USER_NAME"]); $bl_opt = VContacts::getBlockCfg('bl_files', $f_uid, $_SESSION["USER_NAME"]); $f_is = VContacts::getFriendStatus($f_uid); if ($f_is == 1 and ($bl_stat == 0 or ($bl_stat == 1 and $bl_opt == 0))) { if ($return == 1) { return 1; } $q .= "(A.`file_key` = '" . $key . "' AND A.`privacy`!='personal') OR "; } } } else { $q = ''; if ($return == 1) { return 0; } } return $q; } /* 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; $uid = (int) $_SESSION["USER_ID"]; 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`)"; } $ct_today = $ct_slug === 'today' ? 1 : 0; $get_type = self::typeFromPlaylist(); if ($ct_today == 1) { $q = sprintf(" AND A.`last_viewdate`='%s' ", date('Y-m-d')); } $_s = isset($_GET["s"]) ? substr(self::$filter->clr_str($_GET["s"]), 0, 16) : VHref::currentSection(); if ($viewMode_id == '' and isset($_SESSION[$type . "_vm"])) { $viewMode_id = (int) $_SESSION[$type . "_vm"]; } switch ($viewMode_id) { default: case "1": $des = null; $lim = self::$viewMode1_limit; break; case "2": $des = 'SUBSTRING(A.`file_description`, 1, 40) as `file_description`, '; $lim = self::$viewMode3_limit; break; } switch ($_s) { case "file-menu-entry2": //favorites $db_field = 'fav_list'; $db_tbl = 'favorites'; $pg_cfg = 'page_user_files_favorites'; $cache_cfg = 'cache_user_files_favorites'; $categ_query1 = ', B.`db_id` AS `fav_id`'; $categ_query2 = ', `db_' . $type . 'favorites` B'; $categ_query3 = "AND A.`file_key`=B.`file_key`"; $order_table = 'B'; $q .= sprintf(" AND B.`usr_id`='%s' ", $uid); break; case "file-menu-entry3": //liked $db_field = 'liked_list'; $db_tbl = 'liked'; $pg_cfg = 'page_user_files_liked'; $cache_cfg = 'cache_user_files_liked'; $categ_query1 = ', B.`db_id` AS `liked_id`'; $categ_query2 = ', `db_' . $type . 'liked` B'; $categ_query3 = "AND A.`file_key`=B.`file_key`"; $order_table = 'B'; $q .= sprintf(" AND B.`usr_id`='%s' ", $uid); break; case "file-menu-entry4": //history $db_field = 'history_list'; $db_tbl = 'history'; $pg_cfg = 'page_user_files_history'; $cache_cfg = 'cache_user_files_history'; $categ_query1 = ', B.`db_id` AS `history_id`'; $categ_query2 = ', `db_' . $type . 'history` B'; $categ_query3 = "AND A.`file_key`=B.`file_key`"; $order_table = 'B'; $q .= sprintf(" AND B.`usr_id`='%s' ", $uid); break; case "file-menu-entry5": //watchlist $db_field = 'watch_list'; $db_tbl = 'watchlist'; $pg_cfg = 'page_user_files_watchlist'; $cache_cfg = 'cache_user_files_watchlist'; $categ_query1 = ', B.`db_id` AS `watchlist_id`'; $categ_query2 = ', `db_' . $type . 'watchlist` B'; $categ_query3 = "AND A.`file_key`=B.`file_key`"; $q .= sprintf(" AND B.`usr_id`='%s' ", $uid); $order_table = 'B'; break; default: $order_table = 'A'; $pg_cfg = (substr($_REQUEST["s"], 0, 4) == 'subs' or substr($_REQUEST["s"], 0, 4) == 'osub' or substr($_REQUEST["s"], 0, 4) == 'fsub') ? 'page_user_subscriptions_list' : 'page_user_files_uploads'; break; } switch ($_s) { case "file-menu-entry1": default: $pp = true; $uid = (int) $_SESSION["USER_ID"]; $uri = self::$filter->clr_str($_SERVER["REQUEST_URI"]); $a = explode("/", $uri); $t = count($a); if (substr($_s, 0, 4) == 'subs' or substr($_s, 0, 4) == 'osub' or substr($_s, 0, 4) == 'fsub' or $a[$t - 2] == self::$href["subscriptions"] or $a[$t - 2] == self::$href["following"]) { $_ss = VHref::currentSection(); //self::$filter->clr_str($_GET["s"]); $uid = ($a[$t - 2] == self::$href["subscriptions"] or $a[$t - 2] == self::$href["following"]) ? self::$dbc->singleFieldValue('db_accountuser', 'usr_id', 'usr_key', self::$filter->clr_str($a[$t - 1]), (self::$db_cache ? self::$cfg['cache_key_check'] : false)) : (substr($_s, 0, 4) == 'subs' ? str_replace('subs-menu-entry', '', $_ss) : (substr($_s, 0, 4) == 'fsub' ? str_replace('fsub-menu-entry', '', $_ss) : str_replace('osub-menu-entry', '', $_ss))); self::$subscription_section = true; self::$subscription_type = $a[$t - 2] == self::$href["subscriptions"] ? 'subs' : ($a[$t - 2] == self::$href["following"] ? 'fsub' : substr($_s, 0, 4)); $bl_stat = VContacts::getBlockStatus($uid, $_SESSION["USER_NAME"]); $bl_opt = VContacts::getBlockCfg('bl_files', $uid, $_SESSION["USER_NAME"]); $f_is = VContacts::getFriendStatus($uid); if ($f_is == 1 and ($bl_stat == 0 or ($bl_stat == 1 and $bl_opt == 0))) { self::$subscription_private = true; } else { self::$subscription_private = false; } $pg_cfg = 'page_user_subscriptions_list'; $q .= sprintf(" AND A.`approved`='1'"); } $q .= sprintf(" AND A.`usr_id`='%s' ", $uid); break; case "file-menu-entry2": case "file-menu-entry3": case "file-menu-entry4": case "file-menu-entry5": $pp = false; self::$subscription_private = false; break; case "file-menu-entry6": $pp = false; if (strlen($get_type[0]) > 2) { $db_field = $get_type[1]; $db_tbl = $get_type[2]; $pl_q = $get_type[4]; } if (isset($_GET["pp"]) and (int) $_GET["pp"] == 1) { $sql = sprintf("SELECT `%s` FROM `db_%s%s` WHERE `usr_id` > 0 %s LIMIT 1;", $db_field, self::$type, $db_tbl, $pl_q); } else { $sql = sprintf("SELECT `%s` FROM `db_%s%s` WHERE `usr_id`='%s' %s LIMIT 1;", $db_field, self::$type, $db_tbl, self::getUserID(), $pl_q); } $f_sql = self::$db_cache ? self::$db->CacheExecute(self::$cfg[$cache_cfg], $sql) : self::$db->execute($sql); $f_list = $f_sql->fields[$db_field]; if ($f_list != '') { $qq = null; $for = explode("-", self::$filter->clr_str($_GET["s"])); $f_arr = unserialize($f_list); for ($i = 0; $i < count($f_arr); $i++) { $ck = is_array($f_arr[$i]) ? $f_arr[$i][0] : $f_arr[$i]; $qq .= self::fileKeyCheck($type, $ck); } $q .= $qq != '' ? " AND (" . substr($qq, 0, -3) . ")" : null; $pg_cfg = $for[2] == 'entry6' ? 'page_user_files_playlists' : $pg_cfg; } else { $q .= " AND A.`file_key`='0' "; } break; } $sql_1 = null; $sql_2 = null; $search_order = false; if (isset($_GET["sq"]) and strlen($_GET["sq"]) >= 4) { $squery = trim($_GET["sq"]); $rel = VGenerate::prepare($squery); $sql_1 = ", MATCH(`file_title`) AGAINST ('" . $rel . "') AS `Relevance` "; $sql_2 = "MATCH(`file_title`) AGAINST('" . $rel . "' IN BOOLEAN MODE) AND "; $search_order = true; } switch ($sort) { case "public": case "plpublic": case "": $by = $search_order ? "`Relevance` DESC" : $order_table . ".`db_id` DESC"; $qd = "AND A.`privacy`='public' ORDER BY " . $by; $q .= $_s == 'file-menu-entry6' ? (is_array($f_arr) ? sprintf("AND A.`privacy`='public' ORDER BY FIND_IN_SET(A.`file_key`, '%s')", implode(',', $f_arr)) : $qd) : $qd; break; case "private": $by = $search_order ? "`Relevance` DESC" : "A.`file_title` ASC"; $q .= "AND A.`privacy`='" . ($pp ? 'private' : 'public') . "' ORDER BY " . $by; break; case "personal": $by = $search_order ? "`Relevance` DESC" : "A.`file_title` ASC"; $q .= "AND A.`privacy`='" . ($pp ? 'personal' : 'public') . "' ORDER BY " . $by; break; case "recent": $q .= "ORDER BY " . $order_table . ".`db_id` DESC"; break; case "featured": $by = $search_order ? "`Relevance` DESC" : "A.`file_title` ASC"; $q .= "AND A.`is_featured`='1' ORDER BY " . $by; break; case "promoted": $by = $search_order ? "`Relevance` DESC" : "A.`file_title` ASC"; $q .= "AND A.`is_promoted`='1' ORDER BY " . $by; break; case "views": // case "plviews": $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; } if ($type == 'live' and (self::$subscription_section or self::$section == self::$href['subscriptions'])) { $sql_2 .= sprintf(" A.`stream_ended`='1' AND "); } $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.`deleted`='0' AND A.`active`='1' AND A.`usr_id`=D.`usr_id` %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"]; $pages = new VPagination; $pages->items_total = $total; $pages->mid_range = 10; $pages->items_per_page = isset($_GET["ipp"]) ? (int) $_GET["ipp"] : $lim; $pages->paginate(); if (isset($_GET["pp"]) and (int) $_GET["pp"] == 1) { $pages->limit = null; } $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.`file_title`, A.`file_name`, A.`thumb_preview`, A.`thumb_cache`, %s D.`usr_dname`, D.`usr_id`, D.`usr_key`, D.`usr_user`, D.`usr_partner`, D.`usr_affiliate`, D.`affiliate_badge`, D.`ch_title`, D.`usr_photo`, D.`usr_profileinc` %s %s FROM `db_%sfiles` A, `db_accountuser` D %s WHERE %s A.`deleted`='0' AND A.`active`='1' AND A.`usr_id`=D.`usr_id` %s %s %s", $des, $categ_query1, $sql_1, $type, $categ_query2, $sql_2, $categ_query3, $q, $pages->limit); $res = self::$db_cache ? self::$db->CacheExecute(self::$cfg['cache_browse_main'], $sql) : self::$db->execute($sql); if (!isset($_GET["pp"])) { $page_of = (($pages->high + 1) > $total) ? $total : ($pages->high + 1); $results_text = $pages->getResultsInfo($page_of, $total, 'left'); $paging_links = $pages->getPaging($total, 'right'); self::$page_links = $paging_links != '' ? '
' . $paging_links . $results_text . '
' : null; } return $res; } /* get user session id */ private static function getUserID() { return (int) $_SESSION["USER_ID"]; } /* get watchlist entries for logged in user */ private static function watchlistEntries() { $list = []; $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'", self::$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; } } /* new nav menu */ private static function nav_menu() { $page_display = self::$smarty->getTemplateVars('page_display'); if (!isset($_SESSION["USER_ID"]) or $page_display == 'tpl_channel' or $page_display == 'tpl_subs') { return; } $is_mobile = VHref::isMobile(); $s = substr(VHref::currentSection(), 0, 16); $tc1 = ($s == 'file-menu-entry1' or (($s == "" and $page_display == "tpl_files") and !isset($_POST["do_reload"]) and $page_display != "tpl_playlists" and $page_display != "tpl_blogs" and $page_display != "tpl_channel" and $page_display != "tpl_search")) ? 'tab-current' : null; $tc1s = ($s == 'file-menu-entry1' or (($s == "" and $page_display == "tpl_files") and !isset($_POST["do_reload"]) and $page_display != "tpl_playlists" and $page_display != "tpl_blogs" and $page_display != "tpl_channel" and $page_display != "tpl_search")) ? ' swiper-slide-current' : null; $tc2 = $s == 'file-menu-entry2' ? 'tab-current' : null; $tc2s = $s == 'file-menu-entry2' ? ' swiper-slide-current' : null; $tc3 = $s == 'file-menu-entry3' ? 'tab-current' : null; $tc3s = $s == 'file-menu-entry3' ? ' swiper-slide-current' : null; $tc4 = $s == 'file-menu-entry4' ? 'tab-current' : null; $tc4s = $s == 'file-menu-entry4' ? ' swiper-slide-current' : null; $tc5 = $s == 'file-menu-entry5' ? 'tab-current' : null; $tc5s = $s == 'file-menu-entry5' ? ' swiper-slide-current' : null; $tc6 = (isset($_POST["do_reload"]) or $page_display == "tpl_playlists" or ($s == 'file-menu-entry6' and $page_display != "tpl_channel")) ? 'tab-current' : null; $tc6s = (isset($_POST["do_reload"]) or $page_display == "tpl_playlists" or ($s == 'file-menu-entry6' and $page_display != "tpl_channel")) ? ' swiper-slide-current' : null; $tc7 = $s == 'file-menu-entry7' ? 'tab-current' : null; $tc7s = $s == 'file-menu-entry7' ? ' swiper-slide-current' : null; $tc8 = $s == 'file-menu-entry8' ? 'tab-current' : null; $tc8s = $s == 'file-menu-entry8' ? ' swiper-slide-current' : null; $html = '
' . (self::$cfg['file_favorites'] ? ' ' : null) . ' ' . (self::$cfg['file_rating'] ? ' ' : null) . ' ' . (self::$cfg['file_history'] ? ' ' : null) . ' ' . (self::$cfg['file_watchlist'] ? ' ' : null) . ' ' . (self::$cfg['file_playlists'] ? ' ' : null) . ' ' . (self::$cfg['file_comments'] ? ' ' : null) . ' ' . (self::$cfg['file_responses'] ? ' ' : null) . '
'; return $html; } /* file type filters */ private static function typeFilters() { $mm_entry = VHref::currentSection(); $text = self::$cfg["live_module"] == 1 ? '' . self::typeLangReplace(self::$language["files.menu.l.up"]) . '' : null; $text .= self::$cfg["video_module"] == 1 ? '' . self::typeLangReplace(self::$language["files.menu.v.up"]) . '' : null; $text .= self::$cfg["short_module"] == 1 ? '' : null; $text .= self::$cfg["image_module"] == 1 ? '' : null; $text .= self::$cfg["audio_module"] == 1 ? '' : null; $text .= self::$cfg["document_module"] == 1 ? '' : null; $text .= self::$cfg["blog_module"] == 1 ? '' : null; switch ($mm_entry) { case "": case "file-menu-entry1": $ct_class = 'ct-upload'; $text = '' . self::$language['files.menu.myfiles.type']; break; case "file-menu-entry2": $ct_class = 'ct-favorite'; $text = '' . self::$language['files.menu.myfav.type']; break; case "file-menu-entry3": $ct_class = 'ct-like'; $text = '' . self::$language['files.menu.liked.type']; break; case "file-menu-entry4": $ct_class = 'ct-history'; $text = '' . self::$language['files.menu.history.type']; break; case "file-menu-entry5": $ct_class = 'ct-watchlist'; $text = '' . self::$language['files.menu.watch.type']; break; case "file-menu-entry7": $ct_class = 'ct-comment'; break; case "file-menu-entry8": $ct_class = 'ct-response'; break; default: $ct_class = self::$subscription_section ? 'ct-subscription' : 'ct-playlist'; break; } $hide_sort = false; $_s = $mm_entry; if (self::$subscription_section) { if (substr($_s, 0, 4) == 'subs' or substr($_s, 0, 4) == 'osub' or substr($_s, 0, 4) == 'fsub') { $_ss = $_s; $usr_id = substr($_s, 0, 4) == 'subs' ? str_replace('subs-menu-entry', '', $_ss) : (substr($_s, 0, 4) == 'fsub' ? str_replace('fsub-menu-entry', '', $_ss) : str_replace('osub-menu-entry', '', $_ss)); $usr_key = self::$dbc->singleFieldValue('db_accountuser', 'usr_key', 'usr_id', $usr_id, (self::$db_cache ? self::$cfg['cache_key_check'] : false)); } $uinfo = VUserinfo::getUserInfo($usr_id); $user = $uinfo["dname"] != '' ? $uinfo["dname"] : ($uinfo["ch_title"] != '' ? $uinfo["ch_title"] : $uinfo["uname"]); $ch_url = VHref::channelURL(["username" => $uinfo["uname"]]); $text = '' . $user . '' . $user . ''; $ct_class = 'ct-subscription'; } if (isset($_GET["s"])) { $pl_back = null; $_s = self::$filter->clr_str($_GET["s"]); if (strlen($_s) > 16 and substr($_s, 0, 16) == 'file-menu-entry6') { $_r = str_replace('file-menu-entry6-sub', '', $_s); switch ($_r[0]) { case "l": case "v": case "s": case "i": case "a": case "d": case "b": $hide_sort = true; $pl_back = self::$section == self::$href["playlists"] ? '
' : null; $text = ' ' . self::$language['files.menu.mypl2'] . ' ' . self::$dbc->singleFieldValue('db_' . self::$type . 'playlists', 'pl_name', 'pl_id', str_replace($_r[0], '', $_r)) . ' '; $cfg_pl = !isset($_GET["pp"]) ? ' ' : null; } } if ($_s == 'file-menu-entry7' and self::$cfg['file_comments'] == 1) { $menu_li = '
  • ' . self::$language["contacts.invites.approve"] . '
  • '; $menu_li .= '
  • ' . self::$language["contacts.comments.approve"] . '
  • '; $menu_li .= '
  • ' . self::$language["frontend.global.delete.sel"] . '
  • '; } if ($_s == 'file-menu-entry8' and self::$cfg['file_responses'] == 1) { $menu_li = '
  • ' . self::$language["contacts.invites.approve"] . '
  • '; $menu_li .= '
  • ' . self::$language["contacts.comments.approve"] . '
  • '; $menu_li .= '
  • ' . self::$language["frontend.global.delete.sel"] . '
  • '; } } $html = '
    ' . $pl_back . ' ' . (isset($_GET["ch"]) ? '
    ' : null) . ' ' . self::nav_menu() . '

    ' . $text . '

    ' . ((self::$cfg["video_module"] == 1) ? '' : null) . ' ' . ((self::$cfg["short_module"] == 1) ? '' : null) . ' ' . ((self::$cfg["live_module"] == 1) ? '' : null) . ' ' . ((self::$cfg["audio_module"] == 1) ? '' : null) . '
    ' . ((self::$cfg["image_module"] == 1) ? '' : null) . ' ' . ((self::$cfg["document_module"] == 1) ? '' : null) . ' ' . ((self::$cfg["blog_module"] == 1) ? '' : null) . '
    ' . ($hide_sort ? '
    ' : null) . '
    ' . (!isset($_GET["pp"]) ? '
    ' : null) . '
    '; return $html; } /* list available media files */ private static function listMedia($entries, $user_watchlist, $type = false, $hidden = false) { $type = !$type ? self::$type : $type; $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"]); $mm_entry = VHref::currentSection(); $tabs = '
    ' . ('') . ' ' . ((!isset($_GET["pp"]) and self::$cfg["file_privacy"] == 1 and ($mm_entry == '' or $mm_entry == 'file-menu-entry1')) ? '' : null) . ' ' . ((!isset($_GET["pp"]) and self::$cfg["file_privacy"] == 1 and ($mm_entry == '' or $mm_entry == 'file-menu-entry1')) ? '' : null) . ' ' . ('') . ' ' . ('') . ' ' . ('') . ' ' . (self::$cfg["file_favorites"] == 1 ? '' : null) . ' ' . (self::$cfg["file_rating"] == 1 ? '' : null) . ' ' . (self::$cfg["file_comments"] == 1 ? '' : null) . ' ' . (self::$cfg["file_responses"] == 1 ? '' : null) . '
    '; $html = ' '; return $html; } /* viewmode loader */ public static function viewMode_loader($viewMode_id, $entries = false, $user_watchlist = false) { $entries = (isset($_GET["p"]) and (int) $_GET["p"] == 1) ? self::getPromoted($viewMode_id) : (!$entries ? self::getMedia($viewMode_id) : $entries); $section = $entries ? (isset($_GET["sort"]) ? self::$filter->clr_str($_GET["sort"]) : 'public') : 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"]); $content .= self::$page_links; return $content; } /* grid viewmode */ private static function viewMode1($entries, $user_watchlist) { if ($entries->fields["file_key"]) { $li_loop = null; $mm_entry = VHref::currentSection(); $duration_show = (self::$type === 'audio' or self::$type === 'video' or self::$type === 'live') ? 1 : 0; $pl_id = (int) substr($mm_entry, 21); $mobile = VHref::isMobile(); foreach ($entries as $entry) { $title = $entries->fields["file_title"]; $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"]; $file_name = $entries->fields["file_name"]; $usr_key = $entries->fields["usr_key"]; $usr_id = $entries->fields["usr_id"]; $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); $url .= $pl_id > 0 ? '&p=' . self::$dbc->singleFieldValue('db_' . self::$type . 'playlists', 'pl_key', 'pl_id', $pl_id, (self::$db_cache ? self::$cfg['cache_files_playlist_key'] : false)) : null; $ch_url = VHref::channelURL(["username" => $entries->fields["usr_user"]]); $ch_img = VUseraccount::getProfileImage_inc($usr_key, $usr_photo, $usr_inc); $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"]; $file_exists = is_file(self::$cfg["upload_files_dir"] . '/' . $usr_key . '/' . self::$type[0] . '/' . html_entity_decode($file_name, ENT_QUOTES, 'UTF-8')); if (self::$type === 'short' and $duration == '00:00') { $duration_show = 1; } if ($duration_show == 1 and $duration == '00:00') { $conv = !$file_exists ? '' . self::$language["files.text.nofile.err"] . '' : 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) . '
    ' . $thumbnail . ' ' . (!$mobile ? ' ' : null) . ' ' . ($duration_show == 1 ? '
    ' . ($is_live ? self::$language["frontend.global.live"] : (!$conv ? $duration : null)) . '
    ' . $conv . ' ' : null) . '
    ' . (($mm_entry and $mm_entry !== 'file-menu-entry1') ? '
    ' . $user . '
    ' : null) . '

    ' . $title . '

    ' . (($mm_entry and $mm_entry !== 'file-menu-entry1') ? '
    ' . VAffiliate::affiliateBadge($usr_affiliate, $af_badge) . $user . '
    ' : null) . '
    ' . $views . ' ' . ($views == 1 ? self::$language["frontend.global.view"] : self::$language["frontend.global.views"]) . ' ' . $datetime . '
    ' . self::$language["frontend.global.select"] . ' ' . (($usr_id == (int) $_SESSION["USER_ID"] and ($mm_entry == 'file-menu-entry1' or $mm_entry == '')) ? ' ' . self::$language["frontend.global.edit"] . ' ' . self::$language["frontend.global.delete"] . ' ' : null) . '
  • '; } } $html = ' '; return $html; } /* list viewmode */ private static function viewMode2($entries, $user_watchlist) { if ($entries->fields["file_key"]) { $li_loop = null; $mm_entry = VHref::currentSection(); $duration_show = (self::$type === 'audio' or self::$type === 'video' or self::$type === 'live') ? 1 : 0; $pl_id = (int) substr($mm_entry, 21); $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"]; $file_name = $entries->fields["file_name"]; $usr_key = $entries->fields["usr_key"]; $usr_id = $entries->fields["usr_id"]; $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); $url .= $pl_id > 0 ? '&p=' . self::$dbc->singleFieldValue('db_' . self::$type . 'playlists', 'pl_key', 'pl_id', $pl_id, (self::$db_cache ? self::$cfg['cache_files_playlist_key'] : false)) : null; $ch_img = VUseraccount::getProfileImage_inc($usr_key, $usr_photo, $usr_inc); $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"]; $file_exists = is_file(self::$cfg["upload_files_dir"] . '/' . $usr_key . '/' . self::$type[0] . '/' . html_entity_decode($file_name, ENT_QUOTES, 'UTF-8')); if (self::$type === 'short' and $duration == '00:00') { $duration_show = 1; } if ($duration_show == 1 and $duration == '00:00') { $conv = !$file_exists ? '' . self::$language["files.text.nofile.err"] . '' : 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 (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) . '
    ' . $thumbnail . ' ' . ($duration_show == 1 ? '
    ' . ($is_live ? self::$language["frontend.global.live"] : (!$conv ? $duration : null)) . '
    ' . $conv . ' ' : null) . ' ' . (!$mobile ? ' ' : null) . '

    ' . $title . '

    ' . nl2br($description) . '

    ' . (($mm_entry and $mm_entry !== 'file-menu-entry1') ? '
    ' . $user . '
    ' : null) . '
    ' . (($mm_entry and $mm_entry !== 'file-menu-entry1') ? '
    ' . VAffiliate::affiliateBadge($usr_affiliate, $af_badge) . $user . '
    ' : null) . '
    ' . $views . ' ' . ($views == 1 ? self::$language["frontend.global.view"] : self::$language["frontend.global.views"]) . ' ' . $datetime . '
    ' . self::$language["frontend.global.select"] . ' ' . (($usr_id == (int) $_SESSION["USER_ID"] and ($mm_entry == 'file-menu-entry1' or $mm_entry == '')) ? ' ' . self::$language["frontend.global.edit"] . ' ' . self::$language["frontend.global.delete"] . ' ' : null) . '
  • '; } } $html = ' '; return $html; } /* generate thumbnail url location */ public static function thumbnail($usr_key, $file_key, $thumb_server = 0, $rand = true) { $thumb_cache = null; $new_key = $usr_key; if (is_array($usr_key)) { $thumb_cache = $usr_key[1]; $usr_key = $usr_key[0]; } if ($thumb_server > 0) { $expires = 0; $custom_policy = 0; $nr = 1; return VGenerate::thumbSigned(self::$type, $file_key, $new_key, $expires, $custom_policy, $nr); } return self::$cfg["media_files_url"] . '/' . $usr_key . '/t/' . $file_key . '/0' . $thumb_cache . '.jpg'; } /* lazy load more */ private static function loadMore($viewMode, $section) { $html = '
    '; return $html; } /* sorting tabs */ private static function tabs($type, $nonav = false) { $mm_entry = VHref::currentSection(); $html = (!$nonav ? '' : null); return $html; } /* sorting tabs */ private static function pl_tabs($type, $nonav = false) { $section = self::$section; $href = self::$href; switch ($section) { case $href["playlists"]: case $href["channel"]: case $href["search"]: $hide = true; break; default: $hide = (self::$subscription_section or !self::$subscription_private) ? true : false; break; } $html = (!$nonav ? '' : null); return $html; } private static function typeLangReplace($src, $type = false) { $type = !$type ? self::$type[0] : $type[0]; return str_replace('##TYPE##', self::$language["frontend.global." . $type . ".p.c"], $src); } private static function pl_typeLangReplace($src, $type = false) { $type = !$type ? self::$type[0] : $type[0]; return str_replace('##TYPE##', self::$language["frontend.global." . $type . ".c"], $src); } /* tab section loader */ public static function tabSection_loader($tabSection, $category = false) { $title_category = $category ? ' ' . $category : null; $typeSection = explode("-", $tabSection); $type = $typeSection[1]; $switchSection = str_replace('-' . $type, '', $tabSection); switch ($switchSection) { case "public": $title = self::typeLangReplace(self::$language["files.menu.public.type"], $type); $icon = 'clock-o'; break; case "private": $title = self::typeLangReplace(self::$language["files.menu.private.type"], $type); $icon = 'key'; break; case "personal": $title = self::typeLangReplace(self::$language["files.menu.personal.type"], $type); $icon = 'lock'; break; case "promoted": $title = self::typeLangReplace(self::$language["files.menu.promoted.type"], $type); $icon = 'bullhorn'; break; case "featured": $title = self::typeLangReplace(self::$language["files.menu.featured.type"], $type); $icon = 'star'; break; case "views": $title = self::typeLangReplace(self::$language["files.menu.viewed.type"], $type); $icon = 'eye'; break; case "likes": $title = self::typeLangReplace(self::$language["files.menu.most.liked.type"], $type); $icon = 'thumbs-up'; break; case "comments": $title = self::typeLangReplace(self::$language["files.menu.commented.type"], $type); $icon = 'comment'; break; case "favorites": $title = self::typeLangReplace(self::$language["files.menu.favorited.type"], $type); $icon = 'heart'; break; case "responses": $title = self::typeLangReplace(self::$language["files.menu.responded.type"], $type); $icon = 'comments'; break; } $html = '
    ' . self::tabs($type) . '

    ' . $title . $title_category . '

    ' . (!$hide ? '
    ' . self::$language["files.menu.sort.by"] . '
    :
    ' : null) . '
    '; return $html; } /* playlist tab section loader */ public static function pl_tabSection_loader($tabSection, $category = false) { $title_category = $category ? ' ' . $category : null; $typeSection = explode("-", $tabSection); $type = $typeSection[1]; $switchSection = str_replace('-' . $type, '', $tabSection); switch ($switchSection) { case "plpublic": $title = self::pl_typeLangReplace(self::$language["playlist.section.title.public"], $type); $icon = 'clock-o'; break; case "private": $title = self::pl_typeLangReplace(self::$language["playlist.section.title.private"], $type); $icon = 'key'; break; case "personal": $title = self::pl_typeLangReplace(self::$language["playlist.section.title.personal"], $type); $icon = 'lock'; break; case "plviews": $title = self::pl_typeLangReplace(self::$language["playlist.section.title.views"], $type); $icon = 'eye'; break; case "titleasc": $title = self::pl_typeLangReplace(self::$language["playlist.section.title.titleasc"], $type); $icon = 'text-height'; break; case "titledesc": $title = self::pl_typeLangReplace(self::$language["playlist.section.title.titledesc"], $type); $icon = 'text-height'; break; } $html = '
    ' . self::pl_tabs($type) . '

    ' . $title . $title_category . '

    ' . self::$language["files.menu.sort.by"] . '
    :
    '; return $html; } /* confirm deleting lightbox */ public static function doConfirm() { $language = self::$language; $class_filter = self::$filter; $file_key = $class_filter->clr_str($_GET["k"]); switch ($file_key) { case "selected": $ask = $language["notif.confirm.delete.multi"]; $js_do = '$(\'#cb-delete\').click(); $.fancybox.close();'; $js_no = '$(\'#\'+$(\'.main-view-mode-\'+$(\'.view-mode-type.active\').attr(\'id\').replace(\'view-mode-\', \'\')+\'.active\').attr(\'id\')+\'-list .list-check\').prev().click(); $.fancybox.close();'; break; default: $type = $class_filter->clr_str($_GET["t"]); $ask = str_replace('##TYPE##', self::$language["frontend.global." . $type[0]], $language["notif.confirm.delete.type"]); $js_do = '$(\'#\'+$(\'.main-view-mode-\'+$(\'.view-mode-type.active\').attr(\'id\').replace(\'view-mode-\', \'\')+\'.active\').attr(\'id\')+\'-list #file-check' . $file_key . '\').prev().click(); $(\'#cb-delete\').click(); $.fancybox.close();'; $js_no = '$.fancybox.close();'; break; } $html = '

    ' . $language["files.action.del.confirm"] . '

    ' . $ask . '


    ' . $language["frontend.global.cancel"] . '

    '; echo $html; } /* inner section */ public function sectionWrap() { self::$smarty->assign('page_display', 'tpl_files'); self::$smarty->display('tpl_frontend/tpl_file/tpl_files.tpl'); } /* subscription options */ private static function subsConfig() { $cfg = self::$cfg; $language = self::$language; $class_filter = self::$filter; $class_database = self::$dbc; $db = self::$db; $_s = VHref::currentSection(); $sub_id = (int) substr($_s, 15); $rs = $db->execute(sprintf("SELECT `db_id`, `sub_type`, `mail_new_uploads` FROM `%s` WHERE `usr_id`='%s' AND `sub_id`='%s' LIMIT 1;", ($_s[0] == 's' ? 'db_subscribers' : 'db_followers'), $sub_id, (int) $_SESSION["USER_ID"] )); if ($rs->fields["db_id"]) { $is = true; $sub_type = $rs->fields["sub_type"]; $mail_uploads = $rs->fields["mail_new_uploads"]; $uinfo = $db->execute(sprintf("SELECT `usr_key`, `usr_user` FROM `db_accountuser` WHERE `usr_id`='%s' LIMIT 1;", $sub_id)); $s_key = $uinfo->fields["usr_key"]; $s_user = $uinfo->fields["usr_user"]; } if (!$is) { $ts = self::$db->execute(sprintf("SELECT `db_id`, `expire_time` FROM `db_subtemps` WHERE `usr_id`='%s' AND `usr_id_to`='%s' AND `active`='1' LIMIT 1;", (int) $_SESSION["USER_ID"], $sub_id)); $html = '
    '; $html .= '

    ' . ($_s[0] == 's' ? $language["files.text.subs.edit"] : $language["files.text.follow.edit"]) . '

    '; $html .= '

    ' . ($ts->fields["db_id"] ? $language["files.text.unsub.warn3"] . $ts->fields["expire_time"] : $language["notif.error.invalid.request"]) . '

    '; $html .= '
    '; return $html; } $html = '
    '; $html .= '

    ' . ($_s[0] == 's' ? $language["files.text.subs.edit"] : $language["files.text.follow.edit"]) . '

    '; $html .= '
    '; $html .= '
    '; $html .= '
    '; $html .= '
    '; if ($_s[0] == 's' or $_s[0] == 'f') { $html .= '
    '; $html .= ''; $html .= '
    '; $html .= ''; $html .= ''; $html .= '
    '; $html .= '
    '; $html .= ''; $html .= ''; $html .= '
    '; $html .= '
    '; $html .= '
    '; $html .= ''; $html .= ''; $html .= '
    '; if ($_s[0] == 's') { $html .= '
    ' . str_replace('##USER##', ' $s_user]) . '">' . $s_user . '', $language["files.text.unsub.warn4"]) . '
    '; } else { $html .= '
    '; $html .= ''; $html .= ''; $html .= '
    '; } } else { $html .= ''; $html .= ''; } $html .= '
    '; $html .= VGenerate::simpleDivWrap('row left-float top-bottom-padding', 'save-button-row', VGenerate::basicInput('button', 'subs_config_save', 'save-entry-button button-grey search-button form-button save-subs-config', '', 1, '' . $language["frontend.global.savechanges"] . '') . ' ' . $language["frontend.global.cancel"] . ''); $html .= '
    '; $html .= '
    '; $html .= '
    '; $html .= '
    '; $ht_js = ' $(".save-subs-config").on("click", function(){ var the_url = "' . $cfg["main_url"] . '/' . ($_s[0] == 's' ? VHref::getKey("subscriptions") : VHref::getKey("following")) . ($_s != '' ? '?s=' . $_s . '&a=sub_edit' : '?a=sub_edit') . '"; var the_form = "#sub-form"; $("#subs-tab-edit-option").mask(" "); $.post(the_url, $(the_form).serialize(), function(data){ $("#subs-tab-edit-response").html(data); $("#subs-tab-edit-option").unmask(); }); }); $(".icheck-box input").each(function () { var self = $(this); self.iCheck({ checkboxClass: "icheckbox_square-blue", radioClass: "iradio_square-blue", increaseArea: "20%" }); }); '; $ht_js .= '$(".subs-option-username").html($("#sub' . ($_s[0] == 's' ? '1' : '2') . '-menu li.menu-panel-entry-active span.mm").text());'; $html .= VGenerate::declareJS('$(document).ready(function(){' . $ht_js . '});'); return $html; } /* save subscription settings, inc. unsubscribe */ public static function setSubSettings() { $db = self::$db; $class_database = self::$dbc; $class_filter = self::$filter; $language = self::$language; $_s = $class_filter->clr_str($_GET["s"]); $sub_type = $class_filter->clr_str($_POST["sub_options"]); $new_uploads = (int) $_POST["sub_upload_email"]; $sub_for = $_s[0] == 'o' ? (int) $_SESSION["USER_ID"] : (int) $_POST["sub_for"]; $u_js = '$(".menu-panel-entry-active").replaceWith("");'; $u_js .= 'wrapLoad(current_url+menu_section+"?s="+$("#menu-panel-wrapper>div").attr("id"));'; $u_js .= '$("#"+$("#menu-panel-wrapper>div").attr("id")).addClass("menu-panel-entry-active");'; $u_js .= 'var h2t = $("#"+$("#menu-panel-wrapper>div").attr("id")+">span.bold").text(); h2t = h2t == "" ? $("a.active").html() : h2t;'; $u_js .= '$("h2").text(h2t);'; $rs = $db->execute(sprintf("SELECT `db_id` FROM `%s` WHERE `usr_id`='%s' AND `sub_id`='%s' LIMIT 1;", ($_s[0] == 's' ? 'db_subscribers' : 'db_followers'), $sub_for, (int) $_SESSION["USER_ID"] )); if ($db_id = $rs->fields["db_id"]) { if ($sub_type == 'unsub') { $db->execute(sprintf("DELETE FROM `%s` WHERE `db_id`='%s' LIMIT 1;", ($_s[0] == 's' ? 'db_subscribers' : 'db_followers'), $db_id )); } else { $db->execute(sprintf("UPDATE `%s` SET `sub_type`='%s', `mail_new_uploads`='%s' WHERE `db_id`='%s' LIMIT 1;", ($_s[0] == 's' ? 'db_subscribers' : 'db_followers'), $sub_type, $new_uploads, $db_id )); } } if ($db->Affected_Rows() > 0) { if ($sub_type == 'unsub') { if ($_s[0] == 's') { $db->execute(sprintf("UPDATE `db_accountuser` SET `usr_subcount`=`usr_subcount`-1 WHERE `usr_id`='%s' LIMIT 1;", $sub_for)); } else { $db->execute(sprintf("UPDATE `db_accountuser` SET `usr_followcount`=`usr_followcount`-1 WHERE `usr_id`='%s' LIMIT 1;", $sub_for)); } } echo VGenerate::noticeTpl(' no-top-padding wd97p', '', $language["notif.success.request"]); } } /* browse file comments (when managing files) */ public static function fileComments() { $db = self::$db; $class_filter = self::$filter; $language = self::$language; $cfg = self::$cfg; $entry_id = 'ct-entry-details1'; $type = self::$type; $sort = $class_filter->clr_str($_GET["a"]); $_do = $class_filter->clr_str($_GET["do"]); if ($_do == 'cr-approved' or $_do == 'cr-suspended' or $_do == 'cr-today' or $_do == 'cr-recent') { $sort = $_do; } switch ($sort) { case "cr-approved": default: $sort_sql = "AND A.`c_approved`='1' ORDER BY A.`c_datetime` DESC"; break; case "cr-suspended": $sort_sql = "AND A.`c_approved`='0' ORDER BY A.`c_datetime` DESC"; break; case "cr-today": $sort_sql = sprintf("AND A.`c_datetime` LIKE '%s'", date("Y-m-d") . '%'); break; case "cr-recent": $sort_sql = "ORDER BY A.`c_datetime` DESC"; break; } $sql = sprintf("SELECT A.`file_key`, A.`c_usr_id`, A.`c_key`, A.`c_body`, A.`c_datetime`, A.`c_approved`, A.`c_seen`, B.`usr_id`, C.`usr_user`, C.`usr_key`, C.`usr_partner`, C.`usr_affiliate`, C.`affiliate_badge`, B.`file_title`, C.`usr_dname`, C.`ch_title` FROM `db_%scomments` A, `db_%sfiles` B, `db_accountuser` C WHERE A.`file_key`=B.`file_key` AND B.`usr_id`='%s' AND A.`c_active`='1' AND A.`c_usr_id`=C.`usr_id` %s ", $type, $type, intval($_SESSION["USER_ID"]), $sort_sql); $res = $db->execute($sql); if ($res) { $do = 0; $db_count = $res->recordcount(); $pages = new VPagination; $pages->items_total = $db_count; $pages->mid_range = 5; $pages->items_per_page = isset($_GET["ipp"]) ? (int) $_GET["ipp"] : $cfg["page_user_files_comments"]; $pages->paginate(); $res = $db->execute($sql . $pages->limit . ';'); $page_of = (($pages->high + 1) > $db_count) ? $db_count : ($pages->high + 1); $results_text = $pages->getResultsInfo($page_of, $db_count, 'left'); $paging_links = $pages->getPaging($db_count, 'right'); $html = '
    '; $html .= '
    '; $html .= ''; $html .= $db_count == 0 ? VGenerate::simpleDivWrap('no-content', '', $language["files.text.no.comments"]) : null; $html .= $db_count > 0 ? '
    ' . $paging_links . $results_text . '
    ' : null; $html .= VGenerate::simpleDivWrap('no-display', '', ''); $html .= '
    '; $html .= '
    '; } return $html; } /* browse file responses (when managing files) */ public static function fileResponses() { $db = self::$db; $class_database = self::$dbc; $class_filter = self::$filter; $language = self::$language; $cfg = self::$cfg; $entry_id = 'ct-entry-details1'; $type = self::$type; $sort = $class_filter->clr_str($_GET["a"]); $_do = $class_filter->clr_str($_GET["do"]); if ($_do == 'cr-approved' or $_do == 'cr-suspended' or $_do == 'cr-today' or $_do == 'cr-recent') { $sort = $_do; } $sql = sprintf("SELECT A.`db_id`, A.`usr_id`, A.`file_key` AS `resp`, A.`file_response`, A.`datetime`, A.`active`, B.`file_key`, B.`file_title` FROM `db_%sresponses` A, `db_%sfiles` B WHERE A.`file_key`=B.`file_key` AND B.`usr_id`='%s' ", $type, $type, (int) $_SESSION["USER_ID"]); $rs = $db->execute($sql); if ($rs) { $t_arr = array(); $v_arr = array(); $_arr = array(); $resp = $rs->getrows(); if (count($resp) == 0) { return VGenerate::simpleDivWrap('left-float wdmax center all-paddings5 no-content', '', $language["files.text.no.responses"]); } else { foreach ($resp as $k => $v) { $v_arr[$v["file_response"]] = array( "file_response" => $v["file_response"], "file_key" => $v["file_key"], "file_title" => $v["file_title"], "usr_id" => $v["usr_id"], "date" => $v["datetime"], "active" => $v["active"], ); if ((($sort == 'cr-approved' or $sort == '') and $v["active"] == 1) or ($sort == 'cr-suspended' and $v["active"] == 0) or ($sort == 'cr-today' and (substr($v["datetime"], 0, 10) == date("Y-m-d")))) { $q .= " (B.`file_key`='" . $v["file_key"] . "' AND A.`usr_id`=C.`usr_id`) OR "; $t_arr[$v["file_response"]] = strtotime($v["datetime"]); } } $q = $q != '' ? ' AND (' . substr($q, 0, -4) . ')' : ' AND B.`usr_id`=\'0\''; $sql = sprintf("SELECT A.`file_response` AS `resp`, B.`usr_id`, C.`usr_user`, C.`usr_key`, C.`usr_partner`, C.`usr_affiliate`, C.`affiliate_badge`, B.`file_title`, B.`file_key`, B.`thumb_cache`, C.`usr_dname`, C.`ch_title` FROM `db_%sresponses` A, `db_%sfiles` B, `db_accountuser` C WHERE A.`usr_id`=C.`usr_id` AND A.`file_key`=B.`file_key` %s ", $type, $type, $q); $res = $db->execute($sql); } $do = 0; $db_count = $res->recordcount(); $pages = new VPagination; $pages->items_total = $db_count; $pages->mid_range = 5; $pages->items_per_page = isset($_GET["ipp"]) ? (int) $_GET["ipp"] : $cfg["page_user_files_responses"]; $pages->paginate(); $res = $db->execute($sql . $pages->limit . ';'); $pg_count = $res->recordcount(); $page_of = (($pages->high + 1) > $db_count) ? $db_count : ($pages->high + 1); $results_text = $pages->getResultsInfo($page_of, $db_count, 'left'); $paging_links = $pages->getPaging($db_count, 'right'); arsort($t_arr); $html = '
    '; $html .= '
    '; $html .= ''; $html .= $db_count == 0 ? VGenerate::simpleDivWrap('left-float wdmax center all-paddings5 no-content', '', $language["files.text.no.responses"]) : null; $html .= $db_count > 0 ? '
    ' . $paging_links . $results_text . '
    ' : null; $html .= VGenerate::simpleDivWrap('no-display', '', ''); $html .= '
    '; $html .= '
    '; } return $html; } /* comment actions (when browsing comments/own files) */ public static function ownCommentActions($action) { $db = self::$db; $cfg = self::$cfg; $language = self::$language; $class_filter = self::$filter; $err = 0; $type = self::$type; $c_key = $class_filter->clr_str($_POST["section_subject_value"]); switch ($action) { case "comm-disable": case "comm-enable": $notice = 1; $sql = sprintf("UPDATE `db_%scomments` SET `c_approved`='%s' WHERE `c_key`='%s' LIMIT 1;", $type, ($action == 'comm-disable' ? 0 : 1), $c_key); break; case "comm-delete": $notice = 1; $sql = sprintf("DELETE FROM `db_%scomments` WHERE `c_key`='%s' LIMIT 1;", $type, $c_key); $rk = $db->execute(sprintf("SELECT `file_key` FROM `db_%scomments` WHERE `c_key`='%s' LIMIT 1;", $type, $c_key)); $ru = $db->execute(sprintf("UPDATE `db_%sfiles` SET `file_comments`=`file_comments`-1 WHERE `file_key`='%s' LIMIT 1;", $type, $rk->fields["file_key"])); break; case "cb-disable": case "cb-enable": case "cb-commdel": $notice = 1; if (is_array($_POST["entryid"]) and count($_POST["entryid"]) > 0) { foreach ($_POST["entryid"] as $k => $v) { $v = $class_filter->clr_str($v); if ($action == 'cb-commdel') { $rk = $db->execute(sprintf("SELECT `file_key` FROM `db_%scomments` WHERE `c_key`='%s' LIMIT 1;", $type, $v)); $ru = $db->execute(sprintf("UPDATE `db_%sfiles` SET `file_comments`=`file_comments`-1 WHERE `file_key`='%s' LIMIT 1;", $type, $rk->fields["file_key"])); } $q .= "`c_key`='" . $v . "' OR "; } $q = substr($q, 0, -4); } else { $err = 1; } $sql = $action != 'cb-commdel' ? sprintf("UPDATE `db_%scomments` SET `c_approved`='%s' WHERE (%s);", $type, ($action == 'cb-disable' ? 0 : 1), $q) : sprintf("DELETE FROM `db_%scomments` WHERE (%s);", $type, $q); break; } $res = $db->execute($sql); $upd = $db->Affected_Rows(); if ($upd > 0) { if ($cfg["activity_logging"] == 1) { if ($action == 'comm-enable' or $action == 'cb-enable') { $dbu = $db->execute("UPDATE `db_useractivity` SET `act_deleted`='0' WHERE `act_type` LIKE '%" . $c_key . "%';"); } else { $dbu = $db->execute("UPDATE `db_useractivity` SET `act_deleted`='1' WHERE `act_type` LIKE '%" . $c_key . "%';"); } } } if ($upd > 0 and $notice == 1) { echo $html = VGenerate::noticeWrap(array('', '', VGenerate::noticeTpl('', '', $language["notif.success.request"]))); echo $js = VGenerate::declareJS('$("#cb-response-wrap").insertBefore("#gen-file-actions");'); } else { if ($err == 1) { echo $html = VGenerate::noticeWrap(array('', '', VGenerate::noticeTpl('', $language["notif.no.multiple.select"], ''))); } echo $js = VGenerate::declareJS('$("#cb-response-wrap").insertBefore("#gen-file-actions");'); } } /* response actions (when browsing responses/own files) */ public static function ownResponseActions($action) { $db = self::$db; $cfg = self::$cfg; $language = self::$language; $class_filter = self::$filter; $err = 0; $upd = 0; $notice = 0; $type = self::$type; $c_key = $class_filter->clr_str($_POST["section_subject_value"]); switch ($action) { case "resp-disable": case "resp-enable": case "resp-delete": $sql = self::updateResponseArray($type, $c_key, $action); if (!$sql) { return; } $update = $db->execute($sql); if ($db->Affected_Rows() > 0) { $upd += 1; $notice += 1; if ($action == "resp-delete") { $db->execute(sprintf("UPDATE `db_%sfiles` SET `file_responses`=`file_responses`-1 WHERE `file_key`='%s' LIMIT 1;", $type, $c_key)); } } break; case "cb-rdisable": case "cb-renable": case "cb-rdel": if (is_array($_POST["entryid"]) and count($_POST["entryid"]) > 0) { foreach ($_POST["entryid"] as $k => $v) { $v = $class_filter->clr_str($v); $update = $db->execute(self::updateResponseArray($type, $v, $action)); if ($db->Affected_Rows() > 0) { $upd += 1; $notice += 1; if ($action == "cb-rdel") { $db->execute(sprintf("UPDATE `db_%sfiles` SET `file_responses`=`file_responses`-1 WHERE `file_key`='%s' LIMIT 1;", $type, $v)); } } } } else { $err = 1; } break; } if ($upd > 0 and $notice > 0) { echo $html = VGenerate::noticeWrap(array('', '', VGenerate::noticeTpl('', '', $language["notif.success.request"]))); echo $js = VGenerate::declareJS('$("#cb-response-wrap").insertBefore("#gen-file-actions");'); } else { if ($err == 1) { echo $html = VGenerate::noticeWrap(array('', '', VGenerate::noticeTpl('', $language["notif.no.multiple.select"], ''))); } echo $js = VGenerate::declareJS('$("#cb-response-wrap").insertBefore("#gen-file-actions");'); } } /* update responses array */ public function updateResponseArray($type, $key, $action) { $db = self::$db; $sql = null; if (!$_POST) { return; } switch ($action) { case "resp-disable": case "resp-enable": case "resp-delete": $rkey = (int) $_POST["section_subject_value"]; $key = (int) $_POST["section_subject_value_src"]; $sql = sprintf("SELECT `db_id`, `file_key`, `file_response` FROM `db_%sresponses` WHERE `file_key`='%s' AND `file_response`='%s' LIMIT 1;", $type, $key, $rkey); $rs = $db->execute($sql); if ($db_id = $rs->fields["db_id"]) { if ($action == 'resp-disable' or $action == 'resp-enable') { $active = $action == 'resp-disable' ? 0 : 1; $sql = sprintf("UPDATE `db_%sresponses` SET `active`='%s' WHERE `db_id`='%s' LIMIT 1;", $type, $active, $db_id); } else { $sql = sprintf("DELETE FROM `db_%sresponses` WHERE `db_id`='%s' LIMIT 1;", $type, $db_id); } } break; case "cb-rdisable": case "cb-renable": case "cb-rdel": if (isset($_POST["entryid"]) and isset($_POST["respid"])) { $dbs = array(); foreach ($_POST["entryid"] as $k => $v) { $rkey = (int) $v; $key = (int) $_POST["respid"][$k]; $sql = sprintf("SELECT `db_id`, `file_key`, `file_response` FROM `db_%sresponses` WHERE `file_key`='%s' AND `file_response`='%s' LIMIT 1;", $type, $key, $rkey); $rs = $db->execute($sql); if ($db_id = $rs->fields["db_id"]) { $dbs[] = $db_id; } } if (isset($dbs[0])) { $tt = count($dbs); if ($action == 'cb-rdisable' or $action == 'cb-renable') { $active = $action == 'cb-rdisable' ? 0 : 1; $sql = sprintf("UPDATE `db_%sresponses` SET `active`='%s' WHERE `db_id` IN (%s) LIMIT %s;", $type, $active, implode(',', $dbs), $tt); } else { $sql = sprintf("DELETE FROM `db_%sresponses` WHERE `db_id` IN (%s) LIMIT %s;", $type, implode(',', $dbs), $tt); } } } break; } return $sql; } /* comments and responses top section */ public static function CR_tophtml($for = 'comments') { $type = self::$type; $_s = VHref::currentSection(); if ($_s) { if ($_s == 'file-menu-entry7' and self::$cfg['file_comments'] == 1) { $text = str_replace('##TYPE##', self::$language['frontend.global.' . self::$type[0] . '.c'], self::$language['files.menu.type.comm']); $rep = self::$language["files.menu.type.comm"]; $menu_li = '
  • ' . self::$language["contacts.invites.approve"] . '
  • '; $menu_li .= '
  • ' . self::$language["contacts.comments.approve"] . '
  • '; $menu_li .= '
  • ' . self::$language["frontend.global.delete.sel"] . '
  • '; } if ($_s == 'file-menu-entry8' and self::$cfg['file_responses'] == 1) { $text = str_replace('##TYPE##', self::$language['frontend.global.' . self::$type[0] . '.c'], self::$language['files.menu.type.resp']); $rep = self::$language["files.menu.type.resp"]; $menu_li = '
  • ' . self::$language["contacts.invites.approve"] . '
  • '; $menu_li .= '
  • ' . self::$language["contacts.comments.approve"] . '
  • '; $menu_li .= '
  • ' . self::$language["frontend.global.delete.sel"] . '
  • '; } } else { return; } $_do = (isset($_GET["do"]) and ($_GET["a"] != 'cr-approved' and $_GET["a"] != 'cr-suspended' and $_GET["a"] != 'cr-today')) ? self::$filter->clr_str($_GET["do"]) : ((isset($_GET["a"]) and ($_GET["a"] == 'cr-approved' or $_GET["a"] == 'cr-suspended' or $_GET["a"] == 'cr-today')) ? self::$filter->clr_str($_GET["a"]) : null); if (isset($_GET['page']) and !isset($_GET['a'])) { $_do = null; } $html = null; $tabs = '
    '; $html .= !$_do ? '
    ' . self::nav_menu() . '

    ' . $text . '

    ' . (self::$cfg["video_module"] == 1 ? '' : null) . ' ' . (self::$cfg["short_module"] == 1 ? '' : null) . ' ' . (self::$cfg["live_module"] == 1 ? '' : null) . ' ' . (self::$cfg["image_module"] == 1 ? '' : null) . '
    ' . (self::$cfg["audio_module"] == 1 ? '' : null) . ' ' . (self::$cfg["document_module"] == 1 ? '' : null) . ' ' . (self::$cfg["blog_module"] == 1 ? '' : null) . '
    ' : null; $html .= !$_do ? '
    ' : null; $html .= '
    ' . $tabs . '
    '; $html .= '
    ' . self::$smarty->fetch("tpl_backend/tpl_settings/ct-save-top.tpl") . '
    ' . self::$smarty->fetch("tpl_backend/tpl_settings/ct-save-open-close.tpl") . '
    '; $html .= self::CR_sectioncontent($for, $_do); $html .= self::$smarty->fetch("tpl_backend/tpl_settings/ct-switch-js.tpl") . ' ' . self::$smarty->fetch("tpl_backend/tpl_settings/ct-actions-js.tpl") . ' '; $html .= '
    '; $html .= '
    '; $html .= ' '; $html .= !$_do ? '
    ' : null; //end cr-sections return $html; } /* content filler for comments and responses */ private static function CR_sectioncontent($for, $filter) { $type = self::$type; $list = $for == 'comments' ? self::fileComments() : self::fileResponses(); $ht = '
    ' . (($filter == '' or $filter == 'cr-approved') ? $list : null) . '
    ' . ($filter == 'cr-suspended' ? $list : null) . '
    ' . ($filter == 'cr-today' ? $list : null) . '
    '; $html = '
    ' . (($filter == '' or $filter == 'cr-approved') ? $ht : null) . '
    ' . ($filter == 'cr-suspended' ? $ht : null) . '
    ' . ($filter == 'cr-today' ? $ht : null) . '
    '; return $html; } /* get contacts when sharing playlists */ private static function plShare_listContacts() { $db = self::$db; $ct_rs = $db->execute(sprintf("SELECT `ct_username`, `ct_email` FROM `db_usercontacts` WHERE `usr_id`='%s' AND `ct_blocked`='0' AND `ct_active`='1';", self::getUserID())); if ($ct_rs) { while (!$ct_rs->EOF) { $ct_mail = $ct_rs->fields["ct_email"]; $ct_user = $ct_rs->fields["ct_username"]; $html .= $ct_mail != '' ? '
    ' . $ct_mail . '
    ' : null; $html .= $ct_user != '' ? '
    ' . $ct_user . '
    ' : null; @$ct_rs->MoveNext(); } } $ht_js = 'var pl_to = ""; $(".add-contact").click(function(){pl_to = $("#share_pl_to").val(); var pl_added = pl_to.indexOf($(this).attr("rel")); if(pl_added == -1){ $("#share_pl_to").val($("#share_pl_to").val()+$(this).attr("rel")+","); } });'; $html = '
    ' . $html . '
    '; $html .= VGenerate::declareJS($ht_js); return $html; } /* playlist embed code */ public function playlistEmbedCode($type, $pl_key) { return; //DEPRECATED NOT USED ANYMORE $cfg = self::$cfg; $class_database = self::$dbc; $_w = 800; $_h = 480; $dbf = unserialize($class_database->singleFieldValue('db_' . $type . 'playlists', 'pl_files', 'pl_key', $pl_key)); $file_key = $dbf[0]; if ($type == 'video' or $type == 'audio' or ($type == 'image' and $cfg["image_player"] == 'flow')) { //embed code for video playlists and flowplayer image playlists, audio playlists if (($type == 'video' and $cfg["video_player"] == 'flow') or ($type == 'image' and $cfg["image_player"] == 'flow') or ($type == 'audio' and $cfg["audio_player"] == 'flow')) { $width = $_w; $height = $_h; $swf = $cfg["main_url"] . '/f_modules/m_frontend/m_player/swf/flowplayer.swf'; $cts = $cfg["main_url"] . '/f_modules/m_frontend/m_player/swf/flowplayer.controls-tube.swf'; $pl = $cfg["main_url"] . '/' . $type . '_playlist?p=' . $pl_key; $ec = ''; $ec = null; } elseif ((($type == 'video' or $type == 'live') and $cfg["video_player"] == 'jw') or ($type == 'audio' and $cfg["audio_player"] == 'jw')) { //embed code for jw video and audio playlists $width = $_w; $height = $_h; $swf = $cfg["main_url"] . '/f_modules/m_frontend/m_player/swf/jwplayer.swf'; $pl = $cfg["main_url"] . '/' . $type . '_playlist?p=' . $pl_key; $ec = ''; } } elseif ($type == 'image' and ($cfg["image_player"] == 'jq' or $cfg["image_player"] == 'jw')) { //embed code for jw and jq image playlists $width = $_w; $height = $_h; $swf = $cfg["main_url"] . '/f_modules/m_frontend/m_player/swf/image_playlist.swf'; $pl = $cfg["main_url"] . '/image_playlist?p=' . $pl_key . '&transition=flash&shuffle=false&rotatetime=5'; $ec = ''; $ec .= ''; $ec .= ''; $ec .= ''; $ec .= ''; $ec .= ''; $ec .= ''; $ec .= ''; $ec .= ''; $ec .= ''; $ec .= ''; $ec .= ''; $ec .= ''; $ec .= ''; } return $ec; } /* playlist setup tabs */ public function plCfgTabs() { $cfg = self::$cfg; $db = self::$db; $language = self::$language; $class_filter = self::$filter; $user_id = self::getUserID(); $db_tbl = self::$type; $_s = $class_filter->clr_str($_GET["s"]); $pl_id = (int) substr($_s, 21); $sql = sprintf("SELECT `pl_key`, `pl_name`, `pl_files`, `pl_descr`, `pl_tags`, `pl_privacy`, `pl_embed`, `pl_email`, `pl_social`, `pl_thumb` FROM `db_%splaylists` WHERE `usr_id`='%s' AND `pl_id`='%s' LIMIT 1;", $db_tbl, $user_id, $pl_id); $pl_db = $db->execute($sql); /* playlist details */ $edit = '
    '; $edit .= '
    '; $edit .= '
    '; $edit .= VGenerate::sigleInputEntry('text', '', '', 'left-float', 'playlist_title', 'login-input', $pl_db->fields["pl_name"]); $edit .= VGenerate::sigleInputEntry('textarea-on', '', '', 'left-float', 'playlist_descr', 'ta-input', $pl_db->fields["pl_descr"]); $edit .= VGenerate::sigleInputEntry('text', '', '', 'left-float', 'playlist_tags', 'login-input', $pl_db->fields["pl_tags"]); $edit .= '
     
    ' . VGenerate::basicInput('button', 'playlist_details', 'save-entry-button button-grey search-button form-button playlist-update', '', 1, '' . $language["frontend.global.savechanges"] . '') . '
    '; $edit .= '
    '; $edit .= '
    '; /* playlist privacy */ $privacy = '
    '; $privacy .= '
    '; $privacy .= '
    '; $privacy .= '
    '; $privacy .= 'fields["pl_privacy"] == 'public' ? ' checked="checked"' : null) . '>
    '; $privacy .= '
    fields["pl_privacy"] == 'private' ? ' checked="checked"' : null) . '>
    '; $privacy .= '
    fields["pl_privacy"] == 'personal' ? ' checked="checked"' : null) . '>'; $privacy .= '
    '; $privacy .= '
     
    ' . VGenerate::basicInput('button', 'playlist_privacy', 'save-entry-button button-grey search-button form-button playlist-privacy', '', 1, '' . $language["frontend.global.savechanges"] . '') . '
    '; $privacy .= '
    '; $privacy .= '
    '; /* share playlist */ $share = '
    '; $share .= '
    '; $share .= '
    '; $share .= ''; $share .= '
    '; $share .= '
    '; if ($db_tbl[0] != 'd' and $db_tbl[0] != 'b') { if ($cfg["video_player"] == 'jw') { $share .= ''; $share .= '
    '; $share .= '
    ' . sprintf('', self::playlistEmbedCode($db_tbl, $pl_db->fields["pl_key"])) . '
    '; $share .= '
    '; } } $share .= '
    '; $share .= 'fields["pl_email"] == 1 ? ' checked="checked"' : null) . ' />'; $share .= '
    '; $share .= '
    '; $share .= 'fields["pl_social"] == 1 ? ' checked="checked"' : null) . ' />'; $share .= '
    '; $share .= '
     
    ' . VGenerate::basicInput('button', 'playlist_share', 'save-entry-button button-grey search-button form-button playlist-share', '', 1, '' . $language["frontend.global.savechanges"] . '') . '
    '; $share .= '
    '; $share .= '
    '; /* delete playlist */ $delete = '
    '; $delete .= '
    '; $delete .= '
    '; $delete .= '
    ' . $language["files.text.pl.del.txt1"] . '?'; $delete .= VGenerate::declareJS('$(".pt").html($("#' . $_s . '>span.bold").html());'); $delete .= '
    '; $delete .= '
    ' . $language["files.text.pl.del.txt2"] . '

    '; $delete .= '
    ' . VGenerate::basicInput('button', 'playlist_delete', 'save-entry-button button-grey search-button form-button playlist-delete', '', 1, '' . $language["files.text.pl.del.yes"] . '') . '
    '; $delete .= '
    '; $delete .= '
    '; $p = $pl_db->fields["pl_files"]; $pl = $p != '' ? unserialize($p) : null; /* playlist order */ $order = '
    '; $order .= '
    '; $order .= '
    '; if (is_array($pl)) { $o1 = array(); $o2 = array(); foreach ($pl as $k => $pl_key) { $o1[] = $pl_key; $o2[] = sprintf("'%s'", $pl_key); } $pl_sql = sprintf("SELECT A.`file_key`, A.`thumb_server`, A.`thumb_cache`, A.`file_title`, C.`usr_key` FROM `db_%sfiles` A, `db_accountuser` C WHERE A.`usr_id`=C.`usr_id` AND A.`file_key` IN (%s) ORDER BY FIND_IN_SET(A.`file_key`, '%s') LIMIT %s;", $db_tbl, implode(',', $o2), implode(',', $o1), count($pl)); $rs = $db->execute($pl_sql); if ($rs->fields["file_key"]) { $k = 1; $thumbs = array(); $order .= '
      '; while (!$rs->EOF) { $thumb_cache = $rs->fields["thumb_cache"]; $thumb_cache = $thumb_cache > 1 ? $thumb_cache : null; $thumbs[] = self::thumbnail(array($rs->fields["usr_key"], $thumb_cache), $rs->fields["file_key"], $rs->fields["thumb_server"], false); $order .= '
    1. ' . $rs->fields["file_title"] . '
    2. '; $rs->MoveNext(); $k += 1; } $order .= '
    '; } } else { $order .= $language["files.text.pl.thumb.order"]; } $order .= '
     
    ' . VGenerate::basicInput('button', 'playlist_order', 'save-entry-button button-grey search-button form-button playlist-order', '', 1, '' . $language["frontend.global.savechanges"] . '') . '
    '; $order .= '
    '; $order .= '
    '; /* playlist thumb */ $thumb = '
    '; $thumb .= '
    '; $thumb .= '
    '; if ($thumbs[0] != '') { $thumb .= ''; } else { $thumb .= $language["files.text.pl.thumb.empty"]; } $thumb .= '
     
    ' . VGenerate::basicInput('button', 'playlist_thumb', 'save-entry-button button-grey search-button form-button playlist-thumb', '', 1, '' . $language["frontend.global.savechanges"] . '') . '
    '; $thumb .= '
    '; $thumb .= '
    '; $thumb .= '
    '; $ht_js = '(function() {[].slice.call(document.querySelectorAll(".tabs.pltabs")).forEach(function (el) {new CBPFWTabs(el);});})();'; $ht_js .= '$(function() { $("ol.vertical").sortable(); });'; $ht_js .= '$(".icheck-box input").each(function () { var self = $(this); self.iCheck({ checkboxClass: "icheckbox_square-blue", radioClass: "iradio_square-blue", increaseArea: "20%" }); }); '; $ht_js .= '$("#section-pl-thumb li").click(function(){ t = $(this); if (t.hasClass("thumb-selected")) { return; } t.parent().find(".thumb-selected").removeClass("thumb-selected"); t.addClass("thumb-selected"); $("#new-thumb").val(t.attr("rel-key")); });'; $ht_js .= '$(".playlist-thumb").click(function(){ $("#section-pl-thumb").mask(" "); $.post(current_url + menu_section + "?s=' . $_s . '&m=1&for=sort-' . $db_tbl . '&a=update-thumb", $("#playlist-thumb-form").serialize(), function(data){ $("#playlist-thumb-response").html(data); $("#section-pl-thumb").unmask(); }); });'; $ht_js .= 'enterSubmit("#update-playlist-form input", "#btn-1-playlist_details"); $(".playlist-update").click(function(){ $("#section-pl-edit").mask(" "); $.post(current_url + menu_section + "?s=' . $_s . '&m=1&for=sort-' . $db_tbl . '&a=update-pl", $("#update-playlist-form").serialize(), function(data){ $("#update-playlist-response").html(data); $(".pt").text( $("input[name=\'playlist_title\']").val() ); $("#section-pl-edit").unmask(); }); });'; $ht_js .= 'enterSubmit("#update-privacy-form input", "#btn-1-playlist_privacy"); $(".playlist-privacy").click(function(){ $("#section-pl-privacy").mask(" "); $.post(current_url + menu_section + "?s=' . $_s . '&m=1&for=sort-' . $db_tbl . '&a=update-privacy", $("#update-privacy-form").serialize(), function(data){ $("#update-privacy-response").html(data); $("#section-pl-privacy").unmask(); }); });'; $ht_js .= 'enterSubmit("#update-share-form input", "#btn-1-playlist_share"); $(".playlist-share").click(function(){ $("#section-pl-share").mask(" "); $.post(current_url + menu_section + "?s=' . $_s . '&m=1&for=sort-' . $db_tbl . '&a=embed-pl", $("#embed-playlist-form").serialize(), function(data){ $("#playlist-embed-response").html(data); $("#section-pl-share").unmask(); }); });'; $ht_js .= '$(".playlist-order").click(function(){ $("#section-pl-order").mask(" "); $.post(current_url + menu_section + "?s=' . $_s . '&m=1&for=sort-' . $db_tbl . '&a=update-order", $("#update-order-form").serialize(), function(data){ $("#update-order-response").html(data); $("#section-pl-order").unmask(); }); });'; $ht_js .= '$(document).one("click", ".playlist-delete", function(){ $("#section-pl-delete").mask(" "); $.post(current_url + menu_section + "?s=' . $_s . '&m=1&for=sort-' . $db_tbl . '&a=delete-pl", $("#delete-playlist-form").serialize(), function(data){ $("#playlist-delete-response").html(data); $("#section-pl-delete").unmask(""); $(".fancybox-close").click(); }); });'; $html = '

    ' . $edit . '
    ' . $order . '
    ' . $thumb . '
    ' . $privacy . '
    ' . $share . '
    ' . $delete . '
    '; $html .= VGenerate::declareJS('$(document).ready(function(){' . $ht_js . '});'); echo $html; } /* update playlist entries order */ public static function plUpdateOrder() { $db = self::$db; $language = self::$language; $class_filter = self::$filter; $for = $class_filter->clr_str($_GET["for"]); $_s = $class_filter->clr_str($_GET["s"]); $db_tbl = substr($for, 5); $pl_id = (int) substr($_s, 21); $list = isset($_POST["pl_order"]) ? $_POST["pl_order"] : null; if (is_array($list)) { $clean = array_map(array($class_filter, 'clr_str'), $list); $sql = sprintf("UPDATE `db_%splaylists` SET `pl_files`='%s' WHERE `pl_id`='%s' LIMIT 1;", $db_tbl, serialize($list), $pl_id); $res = $db->execute($sql); if ($db->Affected_Rows() > 0) { echo VGenerate::simpleDivWrap('', '', VGenerate::noticeTpl('', '', $language["notif.success.request"])); exit; } } } /* update playlist entries order */ public static function plUpdateThumbnail() { $db = self::$db; $language = self::$language; $class_filter = self::$filter; $for = $class_filter->clr_str($_GET["for"]); $_s = $class_filter->clr_str($_GET["s"]); $db_tbl = substr($for, 5); $pl_id = (int) substr($_s, 21); $tmb = isset($_POST["new_thumb"]) ? $class_filter->clr_str($_POST["new_thumb"]) : false; if ($tmb) { $sql = sprintf("UPDATE `db_%splaylists` SET `pl_thumb`='%s' WHERE `pl_id`='%s' LIMIT 1;", $db_tbl, $tmb, $pl_id); $res = $db->execute($sql); if ($db->Affected_Rows() > 0) { echo VGenerate::simpleDivWrap('', '', VGenerate::noticeTpl('', '', $language["notif.success.request"])); exit; } } } /* email/share a file/playlist */ public function plMail() { $cfg = self::$cfg; $db = self::$db; $class_database = self::$dbc; $class_filter = self::$filter; $language = self::$language; $href = self::$href; $section = self::$section; $_to = $section == $href["watch"] ? $_POST["file_share_mailto"] : $_POST["share_pl_to"]; $send_to = $_to != '' ? explode(",", $_to) : null; $clear_arr = array(); if ($send_to != '') { foreach ($send_to as $key => $val) { if ($val != '' and strpos($val, "@")) { $clear_arr[$key] = $class_filter->clr_str($val); } elseif ($val != '') { $user_id = VUserinfo::getUserID($class_filter->clr_str($val)); if ($user_id > 0) { $clear_arr[$key] = VUserinfo::getUserEmail($user_id); } } } } if (empty($clear_arr)) { echo VGenerate::noticeTpl('', $language["notif.error.invalid.request"], ''); } else { $mail_do = VNotify::queInit(($section == $href["watch"] ? 'file_share' : 'pl_share'), $clear_arr, ''); if ($section == $href["watch"]) { echo VGenerate::noticeTpl('', '', $language["notif.success.request"]); echo VGenerate::declareJS('$(".file-share-mailto").val("");'); } } } /* subscriptions */ public static function userSubs($total = '') { $db = self::$db; $cfg = self::$cfg; $language = self::$language; $uid = (int) $_SESSION["USER_ID"]; $html = null; $usr_ids = array(); $sub_ids = array(); $follow_ids = array(); if ($cfg["user_subscriptions"] == 1) { $ff = 0; $sql = sprintf("SELECT `db_id`, `usr_id`, `sub_id`, `sub_time`, `sub_type`, `mail_new_uploads` FROM `db_subscribers` WHERE `sub_id`='%s';", $uid); $rs = self::$db_cache ? self::$db->CacheExecute(self::$cfg['cache_user_files_subs_follows'], $sql) : self::$db->execute($sql); if (!$rs->fields["db_id"]) { $ff = 1; $sql = sprintf("SELECT `db_id`, `usr_id_to` FROM `db_subtemps` WHERE `usr_id`='%s' AND `pk_id`>'0' AND `active`='1';", $uid); $rs = self::$db_cache ? self::$db->CacheExecute(self::$cfg['cache_user_files_subs_follows'], $sql) : self::$db->execute($sql); } /* my subscriptions */ if ($rs->fields["db_id"]) { $i = 0; $sub_key = null; if (self::$subscription_section) { $uri = self::$filter->clr_str($_SERVER["REQUEST_URI"]); $a = explode("/", $uri); $t = count($a); $sub_key = $a[$t - 1]; } $html .= '
    '; $html .= ''; $html .= ''; $html .= '
    '; } } if ($cfg["user_follows"] == 1) { $sql = sprintf("SELECT `db_id`, `usr_id`, `sub_id`, `sub_time`, `sub_type`, `mail_new_uploads` FROM `db_followers` WHERE `sub_id`='%s';", $uid); $rs = self::$db_cache ? self::$db->CacheExecute(self::$cfg['cache_user_files_subs_follows'], $sql) : self::$db->execute($sql); if ($rs->fields["db_id"]) { $i = 0; $sub_key = null; if (self::$subscription_section) { $uri = self::$filter->clr_str($_SERVER["REQUEST_URI"]); $a = explode("/", $uri); $t = count($a); $sub_key = $a[$t - 1]; } $html .= '
    '; $html .= ''; $html .= ''; $html .= '
    '; } } if ($total == 2 and $js != '') { return $js; } return $html; } /* update privacy settings */ public function plUpdatePrivacy() { $db = self::$db; $language = self::$language; $class_filter = self::$filter; $for = $class_filter->clr_str($_GET["for"]); $_s = $class_filter->clr_str($_GET["s"]); $db_tbl = substr($for, 5); $pl_id = (int) substr($_s, 21); $pl_priv = $class_filter->clr_str($_POST["option_privacy"]); $query = $db->execute(sprintf("UPDATE `db_%splaylists` SET `pl_privacy`='%s' WHERE `usr_id`='%s' AND `pl_id`='%s' LIMIT 1;", $db_tbl, $pl_priv, self::getUserID(), $pl_id)); if ($db->Affected_Rows() > 0) { echo VGenerate::simpleDivWrap('', '', VGenerate::noticeTpl('', '', $language["notif.success.request"])); exit; } } /* update embed settings */ public function plUpdateEmbed() { $db = self::$db; $language = self::$language; $class_filter = self::$filter; $for = $class_filter->clr_str($_GET["for"]); $_s = $class_filter->clr_str($_GET["s"]); $db_tbl = substr($for, 5); $pl_id = (int) substr($_s, 21); $pl_embed = (int) $_POST["allow_playlist_embed"]; $pl_email = (int) $_POST["allow_playlist_email"]; $pl_social = (int) $_POST["allow_playlist_social"]; $query = $db->execute(sprintf("UPDATE `db_%splaylists` SET `pl_embed`='%s', `pl_email`='%s', `pl_social`='%s' WHERE `usr_id`='%s' AND `pl_id`='%s' LIMIT 1;", $db_tbl, $pl_embed, $pl_email, $pl_social, self::getUserID(), $pl_id)); if ($db->Affected_Rows() > 0) { echo VGenerate::simpleDivWrap('', '', VGenerate::noticeTpl('', '', $language["notif.success.request"])); exit; } } /* saving playlist details */ public function plUpdate() { $db = self::$db; $language = self::$language; $class_filter = self::$filter; $for = $class_filter->clr_str($_GET["for"]); $_s = $class_filter->clr_str($_GET["s"]); $pl_array = array( "pl_name" => $class_filter->clr_str($_POST["playlist_title"]), "pl_descr" => $class_filter->clr_str($_POST["playlist_descr"]), "pl_tags" => $class_filter->clr_str($_POST["playlist_tags"]), ); $db_tbl = substr($for, 5); $pl_id = (int) substr($_s, 21); if ($pl_array["pl_name"] == '') { echo VGenerate::simpleDivWrap('', '', VGenerate::noticeTpl('', $language["files.text.pl.details.err"], '')); exit; } foreach ($pl_array as $dbf => $val) { $q .= "`" . $dbf . "` = '" . $val . "', "; } $query = sprintf("UPDATE `db_%splaylists` SET %s WHERE `usr_id`='%s' AND `pl_id`='%s' LIMIT 1;", $db_tbl, substr($q, 0, -2), self::getUserID(), $pl_id); $pl_db = $db->execute($query); if ($db->Affected_Rows() > 0) { echo VGenerate::declareJS('$("#' . $_s . '>span.normal").html("' . $pl_array["pl_name"] . '"); $(".cb-label-add, .cb-label-clear").html("' . $pl_array["pl_name"] . '");'); echo VGenerate::simpleDivWrap('', '', VGenerate::noticeTpl('', '', $language["notif.success.request"])); exit; } } /* deleting a playlist */ public function plDelete() { $db = self::$db; $class_filter = self::$filter; $language = self::$language; $for = $class_filter->clr_str($_GET["for"]); $_s = $class_filter->clr_str($_GET["s"]); $db_tbl = substr($for, 5); $pl_id = (int) substr($_s, 21); $db_sql = $db->execute(sprintf("DELETE FROM `db_%splaylists` WHERE `usr_id`='%s' AND `pl_id`='%s' LIMIT 1;", $db_tbl, self::getUserID(), $pl_id)); if ($db->Affected_Rows() > 0) { $ht_js = '$("#file-menu-entry6-sub' . $db_tbl[0] . $pl_id . '").detach(); $("#file-menu-entry6.menu-panel-entry").click();'; echo VGenerate::declareJS('$(document).ready(function(){' . $ht_js . '});'); echo VGenerate::simpleDivWrap('', '', VGenerate::noticeTpl('', '', $language["notif.success.request"])); exit; } } /* create new playlists */ public function plAddNew() { $class_database = self::$dbc; $class_filter = self::$filter; $smarty = self::$smarty; $language = self::$language; $db = self::$db; $error = false; $pl_title = $class_filter->clr_str($_POST["add_new_title"]); $pl_descr = $class_filter->clr_str($_POST["add_new_descr"]); $pl_tags = $class_filter->clr_str($_POST["add_new_tags"]); $pl_date = date("Y-m-d H:i:s"); if ($pl_title == '') { $error = $language["notif.error.required.field"] . $language["files.action.new.title"]; } else if ($pl_tags == '') { $error = $language["notif.error.required.field"] . $language["files.action.new.tags"]; } if ($error) { echo VGenerate::noticeTpl('', $error, ''); } if (!$error) { $pl_array = array("usr_id" => self::getUserID(), "pl_key" => strtoupper(VUserinfo::generateRandomString(10)), "pl_name" => $pl_title, "pl_descr" => $pl_descr, "pl_tags" => $pl_tags, "pl_date" => $pl_date, ); $post_type = $class_filter->clr_str($_POST["add_new_type"]); $db_tbl = 'db_' . ($_GET["s"] == 'file-menu-entry6' ? $post_type : substr(self::$filter->clr_str($_GET["for"]), 5)) . 'playlists'; if ($pl_array["pl_name"] == '') { return false; } $db_update = $class_database->doInsert($db_tbl, $pl_array); $db_id = $db->Insert_ID(); if ($db_id > 0) { echo VGenerate::declareJS('$(document).ready(function(){$("#add-new-label-form").get(0).reset();});'); echo VGenerate::noticeTpl('', '', $language["notif.success.request"]); echo '
    '; $ht_js = '$("#reload-form").submit();'; echo VGenerate::declareJS('$(document).ready(function(){' . $ht_js . '});'); } } } /* determine type if a playlist menu entry is clicked */ public function typeFromPlaylist() { $href = self::$href; $section = self::$section; if ($section == $href["browse"]) { return false; } $for = explode("-", self::$filter->clr_str($_GET["s"])); if ($for[2] == 'entry6') { $db_field = 'pl_files'; $db_tbl = 'playlists'; $pl_id = substr($for[3], 3); $pl_type = $pl_id[0]; $pl_id = substr($pl_id, 1); $pl_q = sprintf("AND `pl_id`='%s'", $pl_id); switch ($pl_type) { case "l":$type = 'live'; break; case "v":$type = 'video'; break; case "s":$type = 'short'; break; case "i":$type = 'image'; break; case "a":$type = 'audio'; break; case "d":$type = 'doc'; break; case "b":$type = 'blog'; break; } return array($type, $db_field, $db_tbl, $pl_id, $pl_q); } else { return false; } } /* list available media files */ private static function listPlaylistMedia($entries, $user_watchlist, $type = false, $hidden = false) { $href = self::$href; $section = self::$section; $type = !$type ? self::$type : $type; $category = isset($entries->fields["ct_name"]) ? $entries->fields["ct_name"] : false; $title_category = $category ? ' ' . $category : null; $content = $entries->fields["pl_id"] ? self::listPlaylistMedia_content($type, $entries) : VGenerate::simpleDivWrap('no-content', '', self::$language["frontend.global.results.none"]); $default_section = (isset($_SESSION["q"]) and $_SESSION["q"] != '') ? 'relevance' : 'plpublic'; switch ($section) { case $href["playlists"]: case $href["channel"]: case $href["search"]: $hide = true; break; default: $hide = false; break; } $tabs = '
    '; $html = ''; return $html; } /* list my playlists template */ public function listPlaylists($type = 'video', $return_db_object = false) { $db = self::$db; $cfg = self::$cfg; $language = self::$language; $class_filter = self::$filter; $class_database = self::$dbc; $href = self::$href; $section = self::$section; $c = 0; $usr_id = (int) $_SESSION["USER_ID"]; $user = $_SESSION["USER_NAME"]; $sort = isset($_GET["sort"]) ? $class_filter->clr_str($_GET["sort"]) : null; $page = isset($_GET["page"]) ? (int) $_GET["page"] : 1; $lim = self::$playlist_limit; $q = null; $ch = false; switch ($section) { case $href["playlists"]: case $href["channel"]: case $href["search"]: $qq = " AND `pl_privacy`='public' "; break; default: $qq = null; break; } $adr = self::$filter->clr_str($_SERVER["REQUEST_URI"]); if (strpos($adr, self::$href["channel"]) !== false) { $c = new VChannel; $q .= sprintf(" AND B.`usr_key`='%s' ", VChannel::$user_key); $ch = true; } elseif (isset($_GET["u"])) { $q .= sprintf(" AND B.`usr_key`='%s' ", self::$filter->clr_str($_GET["u"])); $ch = true; } $sql_1 = null; $sql_2 = null; $search_order = false; if (isset($_SESSION["q"]) and $_SESSION["q"] != '') { $rel = VGenerate::prepare($_SESSION["q"]); $sql_1 = ", MATCH(`pl_name`, `pl_tags`) AGAINST ('" . $rel . "') AS `Relevance` "; $sql_2 = " AND MATCH(`pl_name`, `pl_tags`) AGAINST('" . $rel . "' IN BOOLEAN MODE)"; $search_order = true; $search_uf = (int) $_SESSION["uf"]; switch ($search_uf) { case "1": //last hour $q .= sprintf(" AND `pl_date` >= DATE_SUB(NOW(), INTERVAL 1 HOUR) "); break; case "2": //today $q .= sprintf(" AND DATE(`pl_date`) = DATE(NOW()) "); break; case "3": //this week $q .= sprintf(" AND YEARWEEK(`pl_date`) = YEARWEEK(NOW()) "); break; case "4": //this month $q .= sprintf(" AND `pl_date` >= DATE_SUB(NOW(), INTERVAL 1 MONTH) "); break; case "5": //this year $q .= sprintf(" AND YEAR(`pl_date`) = YEAR(NOW()) "); break; } } switch ($sort) { case "titleasc":$q .= $qq . "ORDER BY `pl_name` ASC"; break; case "titledesc":$q .= $qq . "ORDER BY `pl_name` DESC"; break; case "plviews":$q .= $qq . "ORDER BY `pl_views` DESC"; break; case "plpublic":$q .= "AND `pl_privacy`='public' ORDER BY `pl_id` DESC"; break; case "private":$q .= !$ch ? "AND `pl_privacy`='private'" : null; break; case "personal":$q .= !$ch ? "AND `pl_privacy`='personal'" : null; break; default:$q .= !$search_order ? $qq . "ORDER BY `pl_id` DESC" : $qq . "ORDER BY `Relevance` DESC"; } if ($cfg[($type == 'doc' ? 'document' : $type) . "_module"] == 1) { $type = $type == 'document' ? 'doc' : $type; switch ($section) { case $href["playlists"]: case $href["channel"]: case $href["search"]: $db_sql = sprintf("SELECT B.`usr_key`, COUNT(A.`pl_id`) AS `total` %s FROM `db_%splaylists` A, `db_accountuser` B WHERE A.`usr_id`=B.`usr_id` AND A.`pl_active`='1' AND A.`pl_files` != '' %s %s;", $sql_1, $type, $sql_2, $q); $db_sql_t = $db->execute($db_sql); break; default: $db_sql_t = $db->execute(sprintf("SELECT COUNT(`pl_id`) AS `total` FROM `db_%splaylists` WHERE `usr_id`='%s' AND `pl_active`='1' %s;", $type, $usr_id, $q)); break; } $total = $db_sql_t->fields["total"]; $pages1 = new VPagination; $pages1->items_total = $total; $pages1->mid_range = 10; $pages1->items_per_page = isset($_GET["ipp"]) ? (int) $_GET["ipp"] : $lim; $pages1->paginate(); switch ($section) { case $href["playlists"]: case $href["channel"]: case $href["search"]: $hide = true; $h3 = '' . $language["files.menu.mypl"]; $db_sql = sprintf("SELECT A.`pl_id`, A.`usr_id`, A.`pl_key`, A.`pl_name`, A.`pl_views`, A.`pl_descr`, A.`pl_privacy`, A.`pl_date`, A.`pl_thumb`, A.`pl_files`, B.`usr_key`, B.`usr_user`, B.`usr_partner`, B.`usr_affiliate`, B.`affiliate_badge`, B.`usr_dname`, B.`ch_title` %s FROM `db_%splaylists` A, `db_accountuser` B WHERE A.`usr_id`=B.`usr_id` AND A.`pl_files` != '' AND A.`pl_active`='1' %s %s %s;", $sql_1, $type, $sql_2, $q, $pages1->limit); $db_sql = $db->execute($db_sql); break; default: $hide = false; $h3 = '' . $language["files.menu.mypl2"]; $db_sql = sprintf("SELECT A.`usr_id`, A.`pl_id`, A.`pl_key`, A.`pl_name`, A.`pl_views`, A.`pl_descr`, A.`pl_privacy`, A.`pl_date`, A.`pl_thumb`, A.`pl_files`, B.`usr_key`, B.`usr_user`, B.`usr_partner`, B.`usr_affiliate`, B.`affiliate_badge`, B.`usr_dname`, B.`ch_title` FROM `db_%splaylists` A, `db_accountuser` B WHERE A.`usr_id`='%s' AND A.`usr_id`=B.`usr_id` AND A.`pl_active`='1' %s %s;", $type, $usr_id, $q, $pages1->limit); $db_sql = $db->execute($db_sql); break; } if (!$hide) { $page_of = (($pages1->high + 1) > $total) ? $total : ($pages1->high + 1); $results_text = $pages1->getResultsInfo($page_of, $total, 'left'); $paging_links = $pages1->getPaging($total, 'right'); } self::$page_links = (!$hide and $paging_links != '') ? '
    ' . $paging_links . '
     
    ' : null; if ($hide) { if ($page * $lim >= $total) { self::$page_end = true; } } } if ($return_db_object) { return $db_sql; } $html = '
    ' . (($_POST and (int) $_POST["do_reload"] == 1) ? VGenerate::noticeTpl('', '', self::$language["files.text.new.pl"]) : null) . '
    ' . self::nav_menu() . '

    ' . $h3 . '

    ' . ($cfg["video_module"] == 1 ? '' : null) . ' ' . ($cfg["short_module"] == 1 ? '' : null) . ' ' . ($cfg["live_module"] == 1 ? '' : null) . ' ' . ($cfg["image_module"] == 1 ? '' : null) . '
    ' . ($cfg["audio_module"] == 1 ? '' : null) . ' ' . ($cfg["document_module"] == 1 ? '' : null) . ' ' . ($cfg["blog_module"] == 1 ? '' : null) . '
    ' . (!$hide ? '
    ' : null) . '
    '; $html .= '
    '; $html .= $cfg["video_module"] == 1 ? self::listPlaylistMedia($db_sql, $user_watchlist = null, 'video', $hidden = false) : null; $html .= $cfg["short_module"] == 1 ? self::listPlaylistMedia(array(), array(), 'short', $hidden = true) : null; $html .= $cfg["live_module"] == 1 ? self::listPlaylistMedia(array(), array(), 'live', $hidden = true) : null; $html .= $cfg["image_module"] == 1 ? self::listPlaylistMedia(array(), array(), 'image', $hidden = true) : null; $html .= $cfg["audio_module"] == 1 ? self::listPlaylistMedia(array(), array(), 'audio', $hidden = true) : null; $html .= $cfg["document_module"] == 1 ? self::listPlaylistMedia(array(), array(), 'doc', $hidden = true) : null; $html .= $cfg["blog_module"] == 1 ? self::listPlaylistMedia(array(), array(), 'blog', $hidden = true) : null; $html .= '
    '; $ht_js = '$(document).ready(function(){thumbFade(); $(".playlist-edit-action-off").click(function(){var sub_id = $(this).attr("id"); wrapLoad(current_url + menu_section + "?s=file-menu-entry6-" + sub_id + "&for=sort-" + $("#"+sub_id+"_type").val()); $("#file-menu-entry6-"+sub_id).addClass("menu-panel-entry-sub-active"); });'; $ht_js .= '(function () {[].slice.call(document.querySelectorAll(".tabs")).forEach(function (el) {new CBPFWTabs(el);});})(); });'; $html .= VGenerate::declareJS($ht_js); return $html; } public static function plCreateNew() { self::$smarty->display('tpl_frontend/tpl_file/tpl_addplaylist.tpl'); } /* content list playlists */ public function listPlaylistMedia_content($type, $db_sql) { $db = self::$db; $cfg = self::$cfg; $language = self::$language; $class_filter = self::$filter; $class_database = self::$dbc; $viewMode_id = (int) $_GET["m"]; $html = ($db_sql->fields["pl_key"] and (!isset($_GET["page"]) or !isset($_GET["pp"]))) ? '' : null; $html .= (self::$section != self::$href["playlists"] and self::$section != self::$href["channel"]) ? self::$page_links : null; return $html; } /* playlist details template */ public function listPlaylistDetails() { $cfg = self::$cfg; $db = self::$db; $class_database = self::$dbc; $class_filter = self::$filter; $language = self::$language; $s = 0; $mod_array = array("l" => "live", "v" => "video", "s" => "short", "i" => "image", "a" => "audio", "d" => "doc", "b" => "blog"); foreach ($mod_array as $key => $val) { if (strlen($_GET[$key]) >= 10 and $s == 0) { $db_tbl = $val; $db_val = $class_filter->clr_str($_GET[$key]); $s = 1; } } $sql = sprintf("SELECT A.`pl_id`, A.`usr_id`, A.`pl_key`, A.`pl_name`, A.`pl_descr`, A.`pl_privacy`, A.`pl_views`, A.`pl_files`, A.`pl_thumb`, A.`pl_embed`, A.`pl_email`, A.`pl_social`, A.`pl_date`, B.`usr_user`, B.`usr_key`, B.`usr_dname`, B.`usr_affiliate`, B.`usr_partner`, B.`affiliate_badge` FROM `db_%splaylists` A, `db_accountuser` B WHERE A.`usr_id`=B.`usr_id` AND A.`pl_key`='%s' LIMIT 1;", $db_tbl, $db_val); $q_result = $db->execute($sql); $u_id = $q_result->fields["usr_id"]; /* check privacy */ if (($q_result->fields["pl_privacy"] == 'personal' and self::getUserID() != $u_id) or $q_result->fields["pl_name"] == '') { return VGenerate::noticeTpl('', $language["notif.error.invalid.request"], ''); } elseif ($q_result->fields["pl_privacy"] == 'private' and self::getUserID() != $u_id) { $fq = $db->execute(sprintf("SELECT `ct_id` FROM `db_usercontacts` WHERE `usr_id`='%s' AND `ct_username`='%s' AND `ct_friend`='1' AND `ct_blocked`='0' AND `ct_active`='1' LIMIT 1;", $u_id, $_SESSION["USER_NAME"])); if ($fq->fields["ct_id"] == '') { return VGenerate::noticeTpl('', $language["notif.error.invalid.request"], ''); } } /* update views */ if (self::getUserID() != $u_id) { $_ip = $class_filter->clr_str($_SERVER[REM_ADDR]); $db->execute(sprintf("UPDATE `db_%splaylists` SET `pl_views`=`pl_views`+1 WHERE `pl_key`='%s' LIMIT 1;", $db_tbl, $db_val)); } $u_user = $q_result->fields["usr_user"]; $d_user = $q_result->fields["usr_dname"]; $u_name = $d_user != '' ? $d_user : $u_user; $u_files = $q_result->fields["pl_files"]; $f_array = unserialize($u_files); $f_count = $u_files != '' ? self::finalDBcount($db_tbl, $f_array) : 0; $p_views = $q_result->fields["pl_views"]; $u_key = $q_result->fields["usr_key"]; $p_key = $q_result->fields["pl_key"]; $thumb = $q_result->fields["pl_thumb"]; $thumb = ($thumb == '' or $thumb == 0) ? $f_array[0] : $thumb; $plu = $db->execute(sprintf("SELECT A.`usr_key`, B.`usr_id`, B.`thumb_cache` FROM `db_accountuser` A, `db_%sfiles` B WHERE A.`usr_id`=B.`usr_id` AND B.`file_key`='%s' LIMIT 1", $db_tbl, $thumb)); $plu_key = $plu->fields["usr_key"]; $thumb_cache = $plu->fields["thumb_cache"]; $thumb_cache = $thumb_cache > 1 ? $thumb_cache : null; $pl_name = $q_result->fields["pl_name"]; $pl_date = $q_result->fields["pl_date"]; $f_title = $class_database->singleFieldValue('db_' . $db_tbl . 'files', 'file_title', 'file_key', $thumb, (self::$db_cache ? $cfg['cache_playlist_details_tmbsrv'] : false)); $p_embed = $q_result->fields["pl_embed"]; $p_social = $q_result->fields["pl_social"]; $p_email = $q_result->fields["pl_email"]; $usr_affiliate = $q_result->fields["usr_affiliate"]; $usr_partner = $q_result->fields["usr_partner"]; $usr_affiliate = ($usr_affiliate == 1 or $usr_partner == 1) ? 1 : 0; $af_badge = $q_result->fields["affiliate_badge"]; if (self::fileKeyCheck($db_tbl, $thumb, 1) == 1 and $class_database->singleFieldValue('db_' . $db_tbl . 'files', 'deleted', 'file_key', $thumb, (self::$db_cache ? $cfg['cache_playlist_details_deleted'] : false)) == '0') { $tmb_srv = $class_database->singleFieldValue('db_' . $db_tbl . 'files', 'thumb_server', 'file_key', $thumb, (self::$db_cache ? $cfg['cache_playlist_details_tmbsrv'] : false)); $tmb_img = '' . $pl_name . ''; } else { $tmb_img = '' . $pl_name . ''; } $adv = VGenerate::simpleDivWrap('', '', VGenerate::advHTML(28)); /* embed tab */ if ($db_tbl[0] == 'i' or (($db_tbl[0] == 'v' or $db_tbl[0] == 'l') and $cfg["video_player"] == 'jw') or ($db_tbl[0] == 'a' and $cfg["audio_player"] == 'jw')) { $embed_html = '
    ' . self::$language["frontend.global.copy"] . '
    '; $embed_html .= (!isset($_GET["d"]) and $cfg["video_player"] == 'jw' and ($p_embed == 1 or $q_result->fields["usr_id"] == self::getUserID())) ? '
    ' . sprintf('', self::playlistEmbedCode($db_tbl, $p_key)) . '
    ' : null; } else { $embed_html = null; } /* email tab */ $email_html = '
    '; $email_html .= '
    '; $email_html .= '
    '; $email_html .= ''; if (self::getUserID() > 0) { $email_html .= '
    '; $email_html .= '
    '; $email_html .= ''; $email_html .= '
    '; } $email_html .= '
    '; $email_html .= ''; $email_html .= ''; $email_html .= ''; $email_html .= VGenerate::basicInput('button', 'playlist_send', 'symbol-button button-grey search-button form-button post-share-email playlist-send', '', 1, ' ' . $language["frontend.global.send"] . ''); $email_html .= '
    '; $email_html .= '
    '; $email_html .= '
    '; $email_html .= '
    '; /* permalink tab */ $perma_html = '
    ' . self::$language["frontend.global.copy"] . '
    '; $perma_html .= '
    ' . sprintf('', $cfg["main_url"] . '/' . VHref::getKey("playlist") . '?' . $db_tbl[0] . '=' . $p_key) . '
    '; $js = '$(".cancel-plshare").click(function(){$("#fade , #popuprel").hide();});'; if ($db_tbl[0] == 'v' or $db_tbl[0] == 'i' or $db_tbl[0] == 'a' or $db_tbl[0] == 'l') { $js .= ($db_tbl[0] == 'i' or (($db_tbl[0] == 'v' or $db_tbl[0] == 'l') and $cfg["video_player"] == 'jw') or ($db_tbl[0] == 'a' and $cfg["audio_player"] == 'jw')) ? 'var copyTextareaBtn = document.querySelector(\'.js-textareacopybtn\'); copyTextareaBtn.addEventListener(\'click\', function(event) { var copyTextarea = document.querySelector(\'.js-copytextarea\'); copyTextarea.select(); try { var successful = document.execCommand(\'copy\'); } catch (err) {} });' : null; $js .= 'var copyTextareaBtn = document.querySelector(\'.js-textareacopybtn-p2\'); copyTextareaBtn.addEventListener(\'click\', function(event) { var copyTextarea = document.querySelector(\'.js-copytextarea-p2\'); copyTextarea.select(); try { var successful = document.execCommand(\'copy\'); } catch (err) {} });'; } $html = '

    ' . $language["files.text.pl.details.top1"] . '

    ' . VGenerate::advHTML(29) . '
    ' . $tmb_img . ' ' . VGenerate::advHTML(30) . '

    ' . $pl_name . '


    ' . (($db_tbl[0] == 'v' or $db_tbl[0] == 'i' or $db_tbl[0] == 'a' or $db_tbl[0] == 'l') ? '
    ' : null) . '
    ' . VGenerate::advHTML(32) . '
    ' . self::playlistDetailsEntries($db_tbl, $f_count, $u_name, $f_array) . '
    ' . VGenerate::advHTML(34) . '
    '; $html .= ''; $js .= ' $(document).ready(function() { (function () { [].slice.call(document.querySelectorAll(\'.tabs\')).forEach(function (el) { new CBPFWTabs(el); }); })(); $(".pl-save").on("click", function() { $(".video_player_holder_comments").mask(" "); url = current_url + menu_section + "?a=save"; $.post(url, {"type": "' . $db_tbl . '", "key": "' . $p_key . '"}, function(data) { $("#pl-save-response").html(data); $(".video_player_holder_comments").unmask(); }); }); });'; $js .= ' $(".playlist-send").on("click", function() { if($("#share_pl_to").val() != "") { $(".video_player_holder_comments").mask(" "); $.post("' . $cfg["main_url"] . '/' . VHref::getKey("playlist") . '?a=pl-mail", $("#share-playlist-form").serialize(), function(data){ $("#pl-save-response").html(data); $(".video_player_holder_comments").unmask(); }); } });'; $js .= ' $(".pl-share").on("click", function(e) { $(".tabs").stop(true, true).slideToggle(300); });'; $html .= VGenerate::declareJS($js); return $html; } /* save playlist */ public static function savePlaylist() { $cfg = self::$cfg; $db = self::$db; $class_database = self::$dbc; $class_filter = self::$filter; $language = self::$language; if ((int) $_SESSION["USER_ID"] == 0) { echo VGenerate::noticeTpl('', $language["files.text.pl.details.guest"], ''); return; } if ($_POST) { $type = $class_filter->clr_str($_POST["type"]); $key = $class_filter->clr_str($_POST["key"]); $sql = sprintf("SELECT `usr_id`, `pl_files`, `pl_name`, `pl_descr`, `pl_tags`, `pl_thumb` FROM `db_%splaylists` WHERE `pl_key`='%s' LIMIT 1;", $type, $key); $res = $db->execute($sql); $pl = $res->fields["pl_files"]; if ($res->recordcount() == 0) { echo VGenerate::noticeTpl('', $language["notif.error.invalid.request"], ''); } elseif ($res->fields["usr_id"] == self::getUserID()) { echo VGenerate::noticeTpl('', $language["playlist.save.error3"], ''); } elseif ($pl == '') { echo VGenerate::noticeTpl('', $language["playlist.save.error1"], ''); } else { $my = array('usr_id' => self::getUserID(), 'pl_key' => strtoupper(VUserinfo::generateRandomString(10)), 'pl_name' => $res->fields["pl_name"], 'pl_descr' => $res->fields["pl_descr"], 'pl_tags' => $res->fields["pl_tags"], 'pl_thumb' => $res->fields["pl_thumb"], 'pl_date' => date("Y-m-d H:i:s"), 'pl_files' => $res->fields["pl_files"], ); if ($class_database->doInsert('db_' . $type . 'playlists', $my)) { echo VGenerate::noticeTpl('', '', $language["notif.success.request"]); } else { echo VGenerate::noticeTpl('', $language["playlist.save.error2"], ''); } } } } /* list of files when viewing playlist details */ public function playlistDetailsEntries($type, $files_count, $u_name, $pl_files, $privacy = '') { $cfg = self::$cfg; $db = self::$db; $class_database = self::$dbc; $class_filter = self::$filter; $language = self::$language; $pl_id = $class_filter->clr_str($_GET[$type[0]]); if ($pl_files[0] == '') { return; } $sql = sprintf("SELECT B.`file_title`, B.`file_key`, B.`file_duration`, B.`thumb_server`, B.`file_views`, B.`thumb_cache`, C.`usr_key`, C.`usr_user`, C.`usr_dname`, C.`usr_affiliate`, C.`usr_partner`, C.`affiliate_badge` FROM `db_%sfiles` B, `db_accountuser` C WHERE B.`usr_id`=C.`usr_id` AND B.`file_key` IN ('%s') ORDER BY FIND_IN_SET(B.`file_key`, '%s') LIMIT %s", $type, implode("','", $pl_files), implode(',', $pl_files), $files_count); $rs = $db->execute($sql); if ($rs->fields["file_key"]) { $c = 1; $html = '