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 ? '' . self::typeLangReplace(self::$language["files.menu.s.up"]) . '' : null;
$text .= self::$cfg["image_module"] == 1 ? '' . self::typeLangReplace(self::$language["files.menu.i.up"]) . '' : null;
$text .= self::$cfg["audio_module"] == 1 ? '' . self::typeLangReplace(self::$language["files.menu.a.up"]) . '' : null;
$text .= self::$cfg["document_module"] == 1 ? '' . self::typeLangReplace(self::$language["files.menu.d.up"]) . '' : null;
$text .= self::$cfg["blog_module"] == 1 ? '' . self::typeLangReplace(self::$language["files.menu.b.up"]) . '' : 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 . '';
$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 . '
' . (!isset($_GET["pp"]) ? '' . self::$smarty->fetch('tpl_frontend/tpl_file/tpl_search_inner.tpl') . '
' : null) . '
' . ((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 = '
' . $tabs . '
' . self::tabs($type) . '
' . self::typeLangReplace(self::$language["files.menu.recent.type"], $type) . '
' . self::$language["files.menu.sort.by"] . '
:
' . ($default_viewMode == 1 ? $content : null) . '
' . ($default_viewMode == 2 ? $content : null) . '
' . ((!isset($_GET["pp"]) and self::$cfg["file_privacy"] == 1 and (self::$subscription_private or $mm_entry == '' or $mm_entry == 'file-menu-entry1')) ? self::tabSection_loader('private-' . $type, $category) : null) . '
' . ((!isset($_GET["pp"]) and self::$cfg["file_privacy"] == 1 and ($mm_entry == '' or $mm_entry == 'file-menu-entry1')) ? self::tabSection_loader('personal-' . $type, $category) : null) . '
' . (self::tabSection_loader('promoted-' . $type, $category)) . '
' . (self::tabSection_loader('featured-' . $type, $category)) . '
' . (self::tabSection_loader('views-' . $type, $category)) . '
' . (self::$cfg["file_favorites"] == 1 ? self::tabSection_loader('favorites-' . $type, $category) : null) . '
' . (self::$cfg["file_rating"] == 1 ? self::tabSection_loader('likes-' . $type, $category) : null) . '
' . (self::$cfg["file_comments"] == 1 ? self::tabSection_loader('comments-' . $type, $category) : null) . '
' . (self::$cfg["file_responses"] == 1 ? self::tabSection_loader('responses-' . $type, $category) : null) . '
';
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 = '
';
} 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 = '
';
}
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 ? '
' : null) . '
' . $thumbnail . '
' . (!$mobile ? '
' : null) . '
' . ($duration_show == 1 ? '
' . ($is_live ? self::$language["frontend.global.live"] : (!$conv ? $duration : null)) . '
' . $conv . '
' : 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 = '
';
} 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 = '
';
}
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 ? '
' : null) . '
' . $thumbnail . '
' . ($duration_show == 1 ? '
' . ($is_live ? self::$language["frontend.global.live"] : (!$conv ? $duration : null)) . '
' . $conv . '
' : null) . '
' . (!$mobile ? '
' : null) . '
' . nl2br($description) . '
';
}
}
$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 = '
';
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 .= '
';
$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 .= '
';
}
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 .= '
';
}
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 ? '
' : null;
$html .= !$_do ? '' : null;
$html .= '
' . $tabs . '
' . self::$language["files.menu.sort.by"] . '
:
';
$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 != '' ? '' : null;
$html .= $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 = '';
}
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 = '';
/* playlist privacy */
$privacy = '';
/* share playlist */
$share = '';
/* delete playlist */
$delete = '';
$p = $pl_db->fields["pl_files"];
$pl = $p != '' ? unserialize($p) : null;
/* playlist order */
$order = '';
/* playlist 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 = '
';
$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 = '
' . ((isset($_SESSION["q"]) and $_SESSION["q"] != '') ? '
' : null) . '
' . ('
') . '
' . (!$hide ? '
' : null) . '
' . (!$hide ? '
' : null) . '
' . ('
') . '
' . ('
') . '
' . ('
') . '
';
$html = '
' . $tabs . '
' . self::pl_tabs($type) . '
' . ($default_section == 'relevance' ? self::pl_typeLangReplace(self::$language["playlist.section.title.relevant"], $type) : self::pl_typeLangReplace((!$hide ? self::$language["playlist.section.title.public"] : self::$language["playlist.section.title.recent"]), $type)) . '
' . self::$language["files.menu.sort.by"] . '
:
' . VGenerate::advHTML(45) . '
' . $content . '
' . VGenerate::advHTML(46) . '
' . ((isset($_SESSION["q"]) and $_SESSION["q"] != '') ? self::pl_tabSection_loader('plpublic-' . $type, $category) : null) . '
' . ((self::$cfg["file_privacy"] == 1 and !$hide) ? self::pl_tabSection_loader('private-' . $type, $category) : null) . '
' . ((self::$cfg["file_privacy"] == 1 and !$hide) ? self::pl_tabSection_loader('personal-' . $type, $category) : null) . '
' . (self::pl_tabSection_loader('plviews-' . $type, $category)) . '
' . (self::pl_tabSection_loader('titleasc-' . $type, $category)) . '
' . (self::pl_tabSection_loader('titledesc-' . $type, $category)) . '
';
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 != '') ? '' : 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 = '
';
} else {
$tmb_img = '
';
}
$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 = '';
$embed_html .= (!isset($_GET["d"]) and $cfg["video_player"] == 'jw' and ($p_embed == 1 or $q_result->fields["usr_id"] == self::getUserID())) ? '' : null;
} else {
$embed_html = null;
}
/* email tab */
$email_html = '';
/* permalink tab */
$perma_html = '';
$perma_html .= '';
$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) . '
' . 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 = '';
while (!$rs->EOF) {
$title = $rs->fields["file_title"];
$u_key = $rs->fields["usr_key"];
$u_user = $rs->fields["usr_user"];
$d_user = $rs->fields["usr_dname"];
$f_key = $rs->fields["file_key"];
$tmb_srv = $rs->fields["thumb_server"];
$usr_affiliate = $rs->fields["usr_affiliate"];
$usr_partner = $rs->fields["usr_partner"];
$usr_affiliate = ($usr_affiliate == 1 or $usr_partner == 1) ? 1 : 0;
$af_badge = $rs->fields["affiliate_badge"];
$p_views = VFiles::numFormat($rs->fields["file_views"]);
$dur = VFiles::fileDuration($rs->fields["file_duration"]);
$_name = $d_user != '' ? $d_user : $u_user;
$thumb_cache = $rs->fields["thumb_cache"];
$thumb_cache = $thumb_cache > 1 ? $thumb_cache : null;
$html .= ' -
'
;
$c += 1;
$rs->MoveNext();
}
$html .= '';
}
return $html;
}
/* get title, descr from key */
public static function getFileInfo($fkey)
{
global $db, $cfg;
$mod_arr = array("live" => "live", "video" => "video", "short" => "short", "image" => "image", "audio" => "audio", "doc" => "document", "blog" => "blog");
foreach ($mod_arr as $key => $val) {
if ($cfg[$val . "_module"] == 1) {
$sql = sprintf("SELECT `db_id`, `file_title`, `file_description`, `thumb_cache` FROM `%s` WHERE `file_key`='%s';", 'db_' . $key . 'files', (int) $fkey);
$rs = $db->execute($sql);
$rs = self::$db_cache ? $db->CacheExecute(self::$cfg['cache_view_template_file_info'], $sql) : $db->execute($sql);
if ($rs->fields["db_id"]) {
return array("title" => $rs->fields["file_title"], "description" => $rs->fields["file_description"], "type" => $key, "thumb_cache" => $rs->fields["thumb_cache"]);
}
}
}
}
/* number format */
public static function numFormat($for)
{
return VGenerate::nrf($for);
}
/* number format */
public function numFormat2($for)
{
return number_format($for, 0, '', ',');
}
/* playlists thumb menu */
public function addToPl($key, $margin = '', $extra = '')
{
$db = self::$db;
$language = self::$language;
$cfg = self::$cfg;
$class_database = self::$dbc;
$upage_id = null;
$href = self::$href;
$section = self::$section;
if ($_GET["do"] == 'reload' or intval($_SESSION["USER_ID"]) == 0) {return false;}
$cfg[] = $class_database->getConfigurations("file_counts");
$key = $extra == '' ? $key : $key . $extra;
$key = strlen($key) == 12 ? substr($key, 0, -1) : $key;
$key = ($section == $href["browse"] or $section == $href["search"]) ? substr($key, 0, -1) : $key;
$menu_db = $class_database->singleFieldValue('db_filetypemenu', 'value', 'usr_id', intval($_SESSION["USER_ID"]));
$type = $margin == '' ? substr(self::$filter->clr_str($_GET["for"]), 5) : '';
$type = ($type == '' and $section == $href["files"] and $menu_db != '' and $cfg[($menu_db != 'doc' ? $menu_db : 'document') . "_module"] == 1) ? $menu_db : $type;
$type = $type == '' ? ((substr(self::$filter->clr_str($_GET["for"]), 0, 4) == 'sort') ? substr(self::$filter->clr_str($_GET["for"]), 5) : $type) : $type;
$type = $type == '' ? (($_GET["s"] != '' or $_GET["t"] == 'short') ? 'short' : (($_GET["l"] != '' or $_GET["t"] == 'live') ? 'live' : (($_GET["v"] != '' or $_GET["t"] == 'video') ? 'video' : (($_GET["i"] != '' or $_GET["t"] == 'image') ? 'image' : (($_GET["a"] != '' or $_GET["t"] == 'audio') ? 'audio' : (($_GET["d"] != '' or $_GET["t"] == 'doc' or $_GET["t"] == 'document') ? 'doc' : null)))))) : $type;
$db_tbl = $type == '' ? ($cfg["video_module"] == 1 ? 'video' : ($cfg["image_module"] == 1 ? 'image' : ($cfg["audio_module"] == 1 ? 'audio' : ($cfg["document_module"] == 1 ? 'doc' : ($cfg["live_module"] == 1 ? 'live' : ($cfg["short_module"] == 1 ? 'short' : null)))))) : $type;
$lb_sql = sprintf("SELECT `pl_id`, `pl_name`, `pl_files` FROM `db_%splaylists` WHERE `usr_id`='%s';", $db_tbl, intval($_SESSION["USER_ID"]));
$lb = $db->execute($lb_sql);
$lb_add = $language["files.action.pl.add"];
$lb_array = $lb->getrows();
$lb_count = count($lb_array);
$pl_space = ' >';
if ($lb_count > 0) {
for ($i = 0; $i < $lb_count; $i++) {
$u_files = $lb_array[$i][2];
$p_files = unserialize($u_files);
$a_check = (is_array($p_files) and in_array($key, $p_files));
$cb_label = $a_check ? 'cb-label-del' : 'cb-label-add';
if ($a_check) {
$cb_label = 'cb-label-clear';
$i_class = 'icon-checkbox-checked';
$attr = 'false';
} else {
$cb_label = 'cb-label-add';
$i_class = 'icon-checkbox-unchecked';
$attr = 'true';
}
//$p_total = $cfg["file_counts"] == 1 ? ' (' . ($u_files != '' ? self::finalDBcount($db_tbl, unserialize($u_files)) : 0) . ')' : null;
$li_add .= '- ' . (VUserinfo::truncateString($lb_array[$i][1], 17)) . '
';
}
return '';
}
}
/* duration from seconds */
public static function fileDuration($seconds_count)
{
$delimiter = ':';
return ($seconds_count > 3600 ? gmdate("H:i:s", $seconds_count) : gmdate("i:s", $seconds_count));
$seconds = $seconds_count % 60;
$min = floor($seconds_count / 60);
$minutes = $min >= 60 ? ($min - 60) : $min;
$hours = $min >= 60 ? ceil($min / 60) : floor($seconds_count / 3600);
$seconds = str_pad($seconds, 2, "0", STR_PAD_LEFT);
$minutes = str_pad($minutes, 2, "0", STR_PAD_LEFT) . $delimiter;
$hours = $hours > 0 ? str_pad($hours, 2, "0", STR_PAD_LEFT) . $delimiter : '';
return $hours . $minutes . $seconds;
}
/* add to favorites and playlists queries */
public function favplSQL($t, $db_tbl = '', $usr_id = '', $type = '', $sel_count = '', $pl_id = '', $pl_act = '')
{
$db = self::$db;
$class_filter = self::$filter;
$class_database = self::$dbc;
$language = self::$language;
switch ($t) {
case "fav":
$db_field = 'db_id';
$db_t = 'favorites';
break;
case "pl":
$db_field = 'pl_files';
$db_t = 'playlists';
break;
case "liked":
$db_field = 'db_id';
$db_t = 'liked';
break;
case "hist":
$db_field = 'db_id';
$db_t = 'history';
break;
case "watch":
$db_field = 'db_id';
$db_t = 'watchlist';
break;
}
$fav_arr = array();
$f_sql = sprintf("SELECT `%s`%s FROM `db_%s%s` WHERE `usr_id`='%s' %s;", $db_field, ($t != 'pl' ? ', `file_key`' : null), $db_tbl, $db_t, $usr_id, ($t == 'pl' ? "AND `pl_id`='" . $pl_id . "'" : null));
$fav_q = $db->execute($f_sql);
if ($t != 'pl') {
if ($fav_q->fields[$db_field]) {
while (!$fav_q->EOF) {
$fav_arr[] = $fav_q->fields["file_key"];
$fav_q->MoveNext();
}
}
} else {
$fav_list = $fav_q->fields[$db_field];
$fav_arr = $fav_list != '' ? unserialize($fav_list) : array();
}
$msg = false;
for ($i = 0; $i < $sel_count; $i++) {
$post_key = $class_filter->clr_str($_POST["fileid"][$i]);
$post_key = strlen($post_key) > 10 ? substr($post_key, 0, -1) : $post_key;
if ($t != 'pl') {
if (($type == 'cb-favadd' or $type == 'cb-watchadd') and !in_array($post_key, $fav_arr)) {
$ins = array("usr_id" => $usr_id, "file_key" => $post_key, "datetime" => date("Y-m-d H:i:s"));
if ($class_database->doInsert('db_' . $db_tbl . $db_t, $ins)) {
/* increment favorited count */
$db_nr = $type == 'cb-favadd' ? $db->execute(sprintf("UPDATE `db_%sfiles` SET `file_favorite`=`file_favorite`+1 WHERE `file_key`='%s' LIMIT 1;", $db_tbl, $post_key)) : null;
$action = new VActivity($usr_id, 0);
$action->addTo(('log_fav'), $db_tbl . ':' . $post_key);
$msg = true;
}
} elseif (($type == 'cb-favclear' or $type == 'cb-likeclear' or $type == 'cb-watchclear' or $type == 'cb-histclear') and in_array($post_key, $fav_arr)) {
$db->execute(sprintf("DELETE FROM `db_%s%s` WHERE `usr_id`='%s' AND `file_key`='%s' LIMIT 1;", $db_tbl, $db_t, $usr_id, $post_key));
//remove like from ratings table
if ($db->Affected_Rows()) {
if ($type == 'cb-likeclear') {
$f = 0;
$vsql = sprintf("SELECT `file_votes` FROM `db_%srating` WHERE `file_key`='%s' LIMIT 1;", $db_tbl, $post_key);
$vinfo = $db->execute($vsql);
$votes = $vinfo->fields["file_votes"];
$db_arr = $votes != '' ? unserialize($votes) : null;
if (is_array($db_arr)) {
foreach ($db_arr as $key => $val) {
if ($f == 0 and $val["usr_id"] == $_SESSION["USER_ID"]) {
$f = 1;
unset($db_arr[$key]);
$v_update = sprintf("UPDATE `db_%srating` SET `file_votes`='%s' WHERE `file_key`='%s' LIMIT 1;", $db_tbl, serialize($db_arr), $post_key);
$db_update = $v_update != '' ? $db->execute($v_update) : null;
$do_update = $db->Affected_Rows();
if ($do_update) {
$db->execute(sprintf("UPDATE `db_%sfiles` SET `file_like`=`file_like`-1 WHERE `file_key`='%s' LIMIT 1;", $db_tbl, $post_key));
}
}
}
}
}
/* decrement favorited count */
$db_nr = $type == 'cb-favclear' ? $db->execute(sprintf("UPDATE `db_%sfiles` SET `file_favorite`=`file_favorite`-1 WHERE `file_key`='%s' LIMIT 1;", $db_tbl, $post_key)) : null;
$msg = true;
}
} elseif ($type == 'cb-histclear-off') {
}
} elseif ($t == 'pl') {
if ($pl_act == 'add' and !in_array($post_key, $fav_arr)) {
$fav_arr[count($fav_arr)] = $post_key;
} elseif ($pl_act == 'clear' and in_array($post_key, $fav_arr)) {
unset($fav_arr[array_search($post_key, $fav_arr)]);
}
}
}
if ($msg) {
echo $html = VGenerate::noticeWrap(array('', '', VGenerate::noticeTpl('', '', $language["notif.success.request"], '')));
}
if ($t == 'pl') {
switch (count($fav_arr)) {
case "0":
$db_arr = null;
$sql = sprintf("UPDATE `db_%splaylists` SET `pl_files`='' WHERE `usr_id`='%s' AND `pl_id`='%s' LIMIT 1;", $db_tbl, $usr_id, $pl_id);
break;
default:
$fav_arr = array_values($fav_arr);
$db_arr = serialize($fav_arr);
$sql = sprintf("UPDATE `db_%splaylists` SET `pl_files`='%s' WHERE `usr_id`='%s' AND `pl_id`='%s' LIMIT 1;", $db_tbl, $db_arr, $usr_id, $pl_id);
break;
}
return $sql;
}
}
/* delete file from server */
public function fileDelete($del_arr, $db_tbl, $usr_key = '')
{
$db = self::$db;
$cfg = self::$cfg;
$class_database = self::$dbc;
if ($cfg["file_deleting"] == 0) {
return false;
}
$user_key = $usr_key == '' ? $_SESSION["USER_KEY"] : $usr_key;
$user_m = $cfg["media_files_dir"] . '/' . $user_key . '/' . $db_tbl[0] . '/';
$user_u = $cfg["upload_files_dir"] . '/' . $user_key . '/' . $db_tbl[0] . '/';
$user_t = $cfg["media_files_dir"] . '/' . $user_key . '/t/';
$user_v = $cfg["channel_views_dir"] . '/' . $user_key . '/' . $db_tbl[0] . '/';
$del_total = count($del_arr);
if ($del_total > 0) {
foreach ($del_arr as $vval) {
$views_dir = $user_v . $vval;
VFileinfo::doDelete($views_dir);
}
}
if ($del_total > 0 and ($cfg["file_delete_method"] == 2 or $cfg["file_delete_method"] == 4)) {
foreach ($del_arr as $val) {
$fval = md5($cfg["global_salt_key"] . $val);
$src_file = $user_u . ($class_database->singleFieldValue('db_' . $db_tbl . 'files', 'file_name', 'file_key', $val));
$flv_file = $user_m . $val . ($db_tbl == 'video' ? '.flv' : ($db_tbl == 'image' ? '.jpg' : ($db_tbl == 'audio' ? '.mp3' : ($db_tbl == 'doc' ? '.pdf' : ($db_tbl == 'blog' ? '.tplb' : '.txx')))));
$mp3_file = $user_m . $fval . '.mp3';
$mp4a_file = $user_m . $fval . '.mp4';
$gif_file = $user_m . $val . '.gif';
$gifa_file = $user_m . $fval . '.gif';
$png_file = $user_m . $val . '.png';
$pnga_file = $user_m . $fval . '.png';
$jpgf_file = $user_m . $fval . '.jpg';
$mp4_file = $user_m . $val . '.mp4';
$mob_file = $user_m . $val . '.mob.mp4';
$mob_filef = $user_m . $fval . '.mob.mp4';
$pdf_file = $user_m . $val . '.pdf';
$pdff_file = $user_m . $fval . '.pdf';
$mp4_360p = $user_m . $val . '.360p.mp4';
$mp4_360pf = $user_m . $fval . '.360p.mp4';
$mp4_480p = $user_m . $val . '.480p.mp4';
$mp4_480pf = $user_m . $fval . '.480p.mp4';
$mp4_720p = $user_m . $val . '.720p.mp4';
$mp4_720pf = $user_m . $fval . '.720p.mp4';
$mp4_1080p = $user_m . $val . '.1080p.mp4';
$mp4_1080pf = $user_m . $fval . '.1080p.mp4';
$mp4_short = $user_m . $val . '.short.mp4';
$mp4_shortf = $user_m . $fval . '.short.mp4';
$mp4_prv = $user_m . md5($val . "_preview") . '.mp4';
$vpx_360p = $user_m . $val . '.360p.webm';
$vpx_480p = $user_m . $val . '.480p.webm';
$vpx_720p = $user_m . $val . '.720p.webm';
$vpx_1080p = $user_m . $val . '.1080p.webm';
$ogv_360p = $user_m . $val . '.360p.ogv';
$ogv_480p = $user_m . $val . '.480p.ogv';
$ogv_720p = $user_m . $val . '.720p.ogv';
$ogv_1080p = $user_m . $val . '.1080p.ogv';
$tmb_dir = $user_t . $val;
if ($db_tbl != 'blog') {
$do_array = array(
$src_file, $gif_file, $gifa_file, $png_file, $pnga_file, $jpgf_file, $mp4_file, $mp4_prv, $mob_file, $mob_filef, $pdf_file, $pdff_file, $mp4_360p, $mp4_360pf, $mp4_480p, $mp4_480pf, $mp4_720p, $mp4_720pf, $mp4_1080p, $mp4_1080pf, $mp4_short, $mp4_shortf,
$vpx_360p, $vpx_480p, $vpx_720p, $vpx_1080p, $ogv_360p, $ogv_480p, $ogv_720p, $ogv_1080p,
);
foreach ($do_array as $delete_file) {
VFileinfo::doDelete($delete_file);
}
}
VFileinfo::doDelete($mp3_file);
VFileinfo::doDelete($mp4a_file);
VFileinfo::doDelete($flv_file);
VFileinfo::doDelete($tmb_dir);
}
}
if (!is_dir($user_m)) {
mkdir($user_m);
chmod($user_m, 0777);
}
if (!is_dir($user_u)) {
mkdir($user_u);
chmod($user_u, 0777);
}
}
/* delete from other user's favorites,playlists,history,liked,watchlist */
/* to be added later, needs much attention, can result in unpredictable behavior */
public function fileDeleteOther($db_tbl, $_key, $_from)
{
if (is_array($_key)) {
foreach ($_key as $val) {
self::fileDeleteOther_action($db_tbl, $val, $_from);
}
} else {
self::fileDeleteOther_action($db_tbl, $_key, $_from);
}
}
public function fileDeleteOther_action($db_tbl, $_key, $_from)
{
$db = self::$db;
$fsql = sprintf("SELECT A.`usr_id`, B.`usr_key` FROM `db_%s%s` A, `db_accountuser` B WHERE A.`usr_id`=B.`usr_id` AND A.`file_key`='%s'", $db_tbl, $_from[0], $_key);
$fres = $db->execute($fsql);
if ($fres) {
while (!$fres->EOF) {
$usr_id = $fres->fields["usr_id"];
$usr_key = $fres->fields["usr_key"];
$del_arr = array($_key);
$del_other = VFiles::clearFavPl($del_arr, $db_tbl, $usr_id, $usr_key);
$fres->MoveNext();
}
}
}
/* delete also from favorites, playlists, liked, history, user activity, message attch.... when deleting files */
public function clearFavPl($del_arr, $db_tbl, $usr_id = '', $usr_key = '')
{
$db = self::$db;
$dbc = self::$dbc;
$cfg = self::$cfg;
$sql_ar = array();
$usr_id = $usr_id == '' ? intval($_SESSION["USER_ID"]) : $usr_id;
if ($cfg["file_delete_method"] == 1) {
return false;
}
if ($cfg["file_delete_method"] == 2 or $cfg["file_delete_method"] == 4) {
$do_del = self::fileDelete($del_arr, $db_tbl, $usr_key);
}
if ($cfg["file_delete_method"] == 3 or $cfg["file_delete_method"] == 4) {
if ($db_tbl != 'blog') {
$p_sql = sprintf("SELECT `pl_id`, `pl_files` FROM `db_%splaylists` WHERE `usr_id`='%s'", $db_tbl, $usr_id);
$p_q = $db->execute($p_sql);
$p_r = $p_q->getrows();
/* delete from playlists */
for ($i = 0; $i < count($p_r); $i++) {
$p_arr = $p_r[$i]["pl_files"] != '' ? unserialize($p_r[$i]["pl_files"]) : array();
if (count($p_arr) > 0) {
foreach ($del_arr as $uval) {
if (is_array($p_arr) and in_array($uval, $p_arr)) {
unset($p_arr[array_search($uval, $p_arr)]);
}
}
$p_arr = array_values($p_arr);
$sql = sprintf("UPDATE `db_%splaylists` SET `pl_files`='%s' WHERE `usr_id`='%s' AND `pl_id`='%s' LIMIT 1;", $db_tbl, ((count($p_arr) > 0) ? serialize($p_arr) : null), $usr_id, $p_r[$i]["pl_id"]);
$db->execute($sql);
echo $do_js = $usr_key == '' ? VGenerate::declareJS('$("#file-menu-entry6-sub' . $db_tbl[0] . $p_r[$i]["pl_id"] . '-count").html("' . count($p_arr) . '")') : null;
}
}
}
if (count($del_arr) > 0 and ($cfg["file_delete_method"] == 3 or $cfg["file_delete_method"] == 4)) {
foreach ($del_arr as $val) {
/* db count nr */
$db_ct = $db->execute(sprintf("UPDATE `db_accountuser` SET `usr_%s_count`=`usr_%s_count`-1 WHERE `usr_id`='%s' LIMIT 1;", $db_tbl[0], $db_tbl[0], $usr_id));
$cl_msg = $db->execute("UPDATE `db_messaging` SET `msg_" . $db_tbl . "_attch`='0' WHERE `msg_" . $db_tbl . "_attch`='" . $val . "';");
/* delete from favorites */
$db->execute(sprintf("DELETE FROM `db_%sfavorites` WHERE `usr_id`='%s' AND `file_key`='%s' LIMIT 1;", $db_tbl, $usr_id, $val));
/* delete from liked */
$db->execute(sprintf("DELETE FROM `db_%sliked` WHERE `usr_id`='%s' AND `file_key`='%s' LIMIT 1;", $db_tbl, $usr_id, $val));
/* delete from history */
$db->execute(sprintf("DELETE FROM `db_%shistory` WHERE `usr_id`='%s' AND `file_key`='%s' LIMIT 1;", $db_tbl, $usr_id, $val));
/* delete from watchlist */
$db->execute(sprintf("DELETE FROM `db_%swatchlist` WHERE `usr_id`='%s' AND `file_key`='%s' LIMIT 1;", $db_tbl, $usr_id, $val));
/* delete from remote servers */
$rq = $db->execute(sprintf("SELECT `upload_server`, `thumb_server` FROM `db_%sfiles` WHERE `file_key`='%s' LIMIT 1;", $db_tbl, $val));
if ($rq->fields["upload_server"] > 0 or $rq->fields["thumb_server"] > 0) {
VbeServers::remoteDelete($val, $db_tbl);
$r = $db->execute(sprintf("UPDATE `db_%sfiles` SET `upload_server`='0', `thumb_server`='0' WHERE `file_key`='%s' LIMIT 1;", $db_tbl, $val));
}
/* delete from responses, comments, ratings, subtitles, payouts */
$pu = $db->execute(sprintf("DELETE FROM `db_%spayouts` WHERE `file_key`='%s';", $db_tbl, $val));
$ru = $db->execute(sprintf("DELETE FROM `db_%sresponses` WHERE `file_key`='%s';", $db_tbl, $val));
$cu = $db->execute(sprintf("DELETE FROM `db_%scomments` WHERE `file_key`='%s';", $db_tbl, $val));
$cu = $db->execute(sprintf("DELETE FROM `db_%srating` WHERE `file_key`='%s';", $db_tbl, $val));
$cu = $db->execute(sprintf("DELETE FROM `db_%sque` WHERE `file_key`='%s';", $db_tbl, $val));
$cu = $db->execute(sprintf("DELETE FROM `db_%ssubs` WHERE `file_key`='%s';", $db_tbl, $val));
$cu = $db->execute(sprintf("DELETE FROM `db_%stransfers` WHERE `file_key`='%s';", $db_tbl, $val));
$cu = $db->execute(sprintf("UPDATE `db_%splaylists` SET `pl_thumb`='' WHERE `pl_thumb`='%s';", $db_tbl, $val));
$cu = $db_tbl === 'video' ? $db->execute(sprintf("DELETE FROM `db_%sdl` WHERE `file_key`='%s';", $db_tbl, $val)) : null;
/* add live temp */
if ($db_tbl == 'live') {
$fn = $dbc->singleFieldValue('db_livefiles', 'file_name', 'file_key', $val);
if ($fn != '') {
$db->execute(sprintf("INSERT INTO `db_%stemps` (`file_key`, `date`) VALUES ('%s', '%s');", $db_tbl, $fn, date("Y-m-d H:i:s")));
}
}
$rc = $db->execute("SELECT `file_key`, `file_responses` FROM `db_" . $db_tbl . "responses` WHERE `file_responses` LIKE '%" . $val . "%' LIMIT 1;");
if ($rc->fields["file_responses"] != '') {
$f = null;
$r_arr = array();
$r_key = $rc->fields["file_key"];
$r_arr = unserialize($rc->fields["file_responses"]);
foreach ($r_arr as $rk => $rv) {
if ($rv["file_key"] == $val) {
$f = $rk;
}
}
if ($f >= 0) {
unset($r_arr[$f]);
$r_arr = array_values($r_arr);
$r_t = count($r_arr);
if ($r_t == 0) {
$db->execute(sprintf("DELETE FROM `db_%sresponses` WHERE `file_key`='%s' LIMIT 1;", $db_tbl, $r_key));
$db->execute(sprintf("UPDATE `db_%sfiles` SET `file_responses`='0' WHERE `file_key`='%s' LIMIT 1;", $db_tbl, $r_key));
} else {
$db->execute(sprintf("UPDATE `db_%sresponses` SET `file_responses`='%s' WHERE `file_key`='%s' LIMIT 1;", $db_tbl, serialize($r_arr), $r_key));
$db->execute(sprintf("UPDATE `db_%sfiles` SET `file_responses`='%s' WHERE `file_key`='%s' LIMIT 1;", $db_tbl, $r_t, $r_key));
}
}
}
}
}
}
}
/* file checkbox actions */
public static function doActions($type)
{
global $class_filter;
$db = self::$db;
$cfg = self::$cfg;
$class_database = self::$dbc;
$language = self::$language;
$href = self::$href;
$section = self::$section;
$upage_id = null;
$sel_count = isset($_POST["fileid"]) ? (int) count($_POST["fileid"]) : 0;
$sort_type = $class_filter->clr_str($_GET["for"]);
$sort_type = (($section == $href["files"] or $section == $href["subscriptions"] or $section == $href["following"]) and isset($_GET["t"])) ? 'sort-' . $class_filter->clr_str($_GET["t"]) : $sort_type;
$sort_type = $section == $href["watch"] ? 'sort-' . $class_filter->clr_str($_POST["uf_type"]) : $sort_type;
$sort_type = $section == $href["see_responses"] ? 'sort-' . $class_filter->clr_str($_POST["resp_type"]) : $sort_type;
$sort_type = $section == $href["index"] ? 'sort-' . $class_filter->clr_str($_POST["sort_type"]) : $sort_type;
$sort_type = $section == $href["search"] ? 'sort-video' : $sort_type;
$db_tbl = substr($sort_type, 5);
$usr_id = self::getUserID();
if ($usr_id == 0) {
return;
}
switch ($type) {
case "comm-disable":$sql = sprintf("UPDATE `db_%scomments` SET `c_active`='0' WHERE `c_key`='%s' LIMIT 1;", $db_tbl, '');
break;
case "cb-private":$sql = sprintf("UPDATE `db_%sfiles` SET `privacy`='private' WHERE `usr_id`='%s' AND (##KEYS##) LIMIT %s;", $db_tbl, $usr_id, $sel_count);
break;
case "cb-public":$sql = sprintf("UPDATE `db_%sfiles` SET `privacy`='public' WHERE `usr_id`='%s' AND (##KEYS##) LIMIT %s;", $db_tbl, $usr_id, $sel_count);
break;
case "cb-personal":$sql = sprintf("UPDATE `db_%sfiles` SET `privacy`='personal' WHERE `usr_id`='%s' AND (##KEYS##) LIMIT %s;", $db_tbl, $usr_id, $sel_count);
break;
case "cb-favadd":
case "cb-watchadd":
case "cb-watchclear":
case "cb-favclear":
case "cb-likeclear":
case "cb-histclear":
$sql = self::favplSQL(($type == 'cb-likeclear' ? 'liked' : ($type == 'cb-histclear' ? 'hist' : (($type == 'cb-watchadd' or $type == 'cb-watchclear') ? 'watch' : 'fav'))), $db_tbl, $usr_id, $type, $sel_count);
break;
case "cb-delete":
if ($cfg["paid_memberships"] == 1 and ($cfg["file_delete_method"] == 2 or $cfg["file_delete_method"] == 4)) {
$sql_sub = sprintf("SELECT `file_size` FROM `db_%sfiles` WHERE `usr_id`='%s' AND (##KEYS##)", $db_tbl, $usr_id);
}
switch ($cfg["file_delete_method"]) {
case "1":
case "2":
$sql = sprintf("UPDATE `db_%sfiles` SET `deleted`='1' WHERE `usr_id`='%s' AND (##KEYS##)", $db_tbl, $usr_id);
break;
case "3":
case "4":
$sql = sprintf("DELETE `files` FROM `db_%sfiles` AS `files`
WHERE `files`.`usr_id` = '%s' AND (##KEYS##)", $db_tbl, $usr_id);
break;
}
break;
default:
$chk_for = ($section != $href["see_responses"] and $section != $href["user"]) ? $_GET["a"] : $_GET["do"];
if (substr($chk_for, 0, 8) == 'cb-label') {
$type = 'cb-label';
$do_arr = explode("-", $chk_for);
if (substr($do_arr[2], 0, 3) == 'add') {
$pl_id = intval(substr($do_arr[2], 3));
$pl_act = 'add';
} elseif (substr($do_arr[2], 0, 5) == 'clear') {
$pl_id = intval(substr($do_arr[2], 5));
$pl_act = 'clear';
}
$sql = self::favplSQL('pl', $db_tbl, $usr_id, $type, $sel_count, $pl_id, $pl_act);
}
break;
}
if ($sel_count > 0) {
$db_whr_field = 'file_key';
if ($type == 'cb-private' or $type == 'cb-public' or $type == 'cb-personal') {
for ($i = 0; $i < $sel_count; $i++) {$q .= "`" . $db_whr_field . "` = '" . $class_filter->clr_str($_POST["fileid"][$i]) . "' OR ";}
} elseif ($type == 'cb-delete') {
$dbf = ($type == 'cb-delete' and ($cfg["file_delete_method"] == 1 or $cfg["file_delete_method"] == 2)) ? null : "`files`.";
for ($i = 0; $i < $sel_count; $i++) {
$del_arr[$i] = $class_filter->clr_str($_POST["fileid"][$i]);
$q .= $dbf . "`" . $db_whr_field . "` = '" . $class_filter->clr_str($_POST["fileid"][$i]) . "' OR ";
$q1 .= $cfg["paid_memberships"] == 1 ? "(" . $dbf . "`" . $db_whr_field . "` = '" . $class_filter->clr_str($_POST["fileid"][$i]) . "' AND `is_subscription`='1') OR " : null;
}
}
if ($type == 'cb-delete') {
foreach ($del_arr as $dfk) {
// delete from remote servers
$rq = $db->execute(sprintf("SELECT `upload_server`, `thumb_server` FROM `db_%sfiles` WHERE `file_key`='%s' LIMIT 1;", $db_tbl, $dfk));
if ($rq->fields["upload_server"] > 0 or $rq->fields["thumb_server"] > 0) {
VbeServers::remoteDelete($dfk, $db_tbl);
$r = $db->execute(sprintf("UPDATE `db_%sfiles` SET `upload_server`='0', `thumb_server`='0' WHERE `file_key`='%s' LIMIT 1;", $db_tbl, $dfk));
$r = $db->execute(sprintf("DELETE FROM `db_%stransfers` WHERE `file_key`='%s' LIMIT 1;", $db_tbl, $dfk));
}
}
}
$wh_sql = substr($q, 0, -3);
$sql = str_replace("##KEYS##", $wh_sql, $sql);
/* delete from subscription used space */
if ($type == 'cb-delete' and $cfg["paid_memberships"] == 1 and ($cfg["file_delete_method"] == 2 or $cfg["file_delete_method"] == 3 or $cfg["file_delete_method"] == 4)) {
$wh_sql1 = substr($q1, 0, -3);
$sql_sub = str_replace('`files`.', '', str_replace("##KEYS##", $wh_sql1, $sql_sub));
$rsub = $db->execute($sql_sub);
if ($rsub) {
while (!$rsub->EOF) {
$_q = sprintf("UPDATE `db_packusers` SET `pk_usedspace`=`pk_usedspace` - %s, `pk_total_%s`=`pk_total_%s` - 1 WHERE `usr_id`='%s' AND (`pk_usedspace` > 0 OR `pk_total_%s` > 0) LIMIT 1;", $rsub->fields["file_size"], $db_tbl, $db_tbl, $usr_id, $db_tbl);
$db->execute($_q);
@$rsub->MoveNext();
}
}
}
if ($type == 'cb-delete') {
//delete from own entries
$del_fav = self::clearFavPl($del_arr, $db_tbl);
//delete from other user's entries
$del_other = self::fileDeleteOther($db_tbl, $del_arr, array(0 => "favorites", 1 => "fav_list"));
$del_other = self::fileDeleteOther($db_tbl, $del_arr, array(0 => "history", 1 => "history_list"));
$del_other = self::fileDeleteOther($db_tbl, $del_arr, array(0 => "liked", 1 => "liked_list"));
$del_other = self::fileDeleteOther($db_tbl, $del_arr, array(0 => "watchlist", 1 => "watch_list"));
}
if ($sql == '') {
return;
}
$do_action = $db->execute($sql);
if ($do_action) {
if ($cfg["activity_logging"] == 1 and ($type == 'cb-favadd' or $type == 'cb-delete')) {
$action = new VActivity($usr_id, 0);
for ($i = 0; $i < $sel_count; $i++) {
$action->addTo(($type == 'cb-favadd' ? 'log_fav' : 'log_delete'), $db_tbl . ':' . self::keyCheck($class_filter->clr_str($_POST["fileid"][$i])));
$dbu = $type == 'cb-delete' ? $db->execute("UPDATE `db_useractivity` SET `act_deleted`='1' WHERE `act_type` LIKE '%" . $class_filter->clr_str($_POST["fileid"][$i]) . "%';") : null;
}
}
$pl_ct = ($type == 'cb-private' or $type == 'cb-public' or $type == 'cb-personal') ? self::getPlTypes('file-menu-entry6', 0) : null;
if ($upage_id == '') {
echo $html = VGenerate::noticeWrap(array('', '', VGenerate::noticeTpl('', '', $language["notif.success.request"], '')));
}
echo $js = ($upage_id == '' and $section != $href["watch"] and $section != $href["browse"]) ? VGenerate::declareJS($ht_js) : null;
}
if ($section != $href["see_responses"]) {
return true;
}
} else {
echo $html = VGenerate::noticeWrap(array('', '', VGenerate::noticeTpl('', $language["notif.no.multiple.select"], '')));
return false;
}
}
/* db id check */
public function keyCheck($key)
{
global $class_filter;
$new_key = strlen($key) > 10 ? substr($class_filter->clr_str($key), 0, -1) : $class_filter->clr_str($key);
return $new_key;
}
/* get final db count, check private or inactive or not approved files */
public function finalDBcount($db_tbl, $file_array)
{
$db = self::$db;
foreach ($file_array as $val) {
$q .= self::fileKeyCheck($db_tbl, $val);
}
$q = $q != '' ? $q : "(A.`approved`='1' AND A.`deleted`='0') OR ";
$sql = sprintf("SELECT A.`db_id`, A.`usr_id`, A.`file_key`, A.`privacy`, A.`approved`, A.`active` FROM `db_%sfiles` A WHERE A.`active`='1' %s AND A.`usr_id`>'0' AND ", $db_tbl, "");
$cq = $q != '' ? $sql . ' (' . substr($q, 0, -3) . ')' : substr($sql, 0, -4);
$rs = $db->execute($cq);
return $rs->recordcount();
}
/* get db file count */
public function fileCountDB($get_array)
{
return;
/*
!
!
to be removed
!
!
*/
$db = self::$db;
$cfg = self::$cfg;
if ($get_array["db_fields"] != '') {
$sql = sprintf("SELECT %s FROM `db_%s%s` WHERE %s", $get_array["db_select"], $get_array["db_tbl"], $get_array["db_from"], $get_array["db_where"]);
}
$rs = $db->execute($sql);
$rs_db = $get_array["db_fields"] != 'total' ? $rs->fields[$get_array["db_fields"]] : null;
$total = $get_array["db_fields"] != 'total' ? ($rs_db == '' ? 0 : self::finalDBcount($get_array["db_tbl"], unserialize($rs_db))) : $rs->fields["total"];
return $total;
}
/* count files */
public function fileCount($for, $type = '')
{
return;
/*
!
!
to be removed
!
!
*/
$cfg = self::$cfg;
$db = self::$db;
$class_database = self::$dbc;
$href = self::$href;
$section = self::$section;
$usr_id = intval($_SESSION["USER_ID"]);
$type = $type == '' ? substr(self::$filter->clr_str($_GET["for"]), 5) : $type;
$menu_db = $class_database->singleFieldValue('db_filetypemenu', 'value', 'usr_id', $usr_id);
$type = ($section == $href["files"] and $menu_db != '' and $cfg[($menu_db != 'doc' ? $menu_db : 'document') . "_module"] == 1) ? $menu_db : $type;
$db_tbl = $type == '' ? ($cfg["video_module"] == 1 ? 'video' : ($cfg["live_module"] == 1 ? 'live' : ($cfg["image_module"] == 1 ? 'image' : ($cfg["audio_module"] == 1 ? 'audio' : ($cfg["document_module"] == 1 ? 'doc' : ($cfg["short_module"] == 1 ? 'short' : null)))))) : $type;
switch ($for) {
case "file-menu-entry1": //files
$get_array = array("db_select" => "count(`db_id`) AS `total`", "db_tbl" => $db_tbl, "db_from" => "files", "db_where" => "`usr_id`='" . $usr_id . "'", "db_fields" => "total");
break;
case "file-menu-entry2": //favorites
$get_array = array("db_select" => "fav_list", "db_tbl" => $db_tbl, "db_from" => "favorites", "db_where" => "`usr_id`='" . $usr_id . "'", "db_fields" => "fav_list");
break;
case "file-menu-entry3": //liked
$get_array = array("db_select" => "liked_list", "db_tbl" => $db_tbl, "db_from" => "liked", "db_where" => "`usr_id`='" . $usr_id . "'", "db_fields" => "liked_list");
break;
case "file-menu-entry4": //history
$get_array = array("db_select" => "history_list", "db_tbl" => $db_tbl, "db_from" => "history", "db_where" => "`usr_id`='" . $usr_id . "'", "db_fields" => "history_list");
break;
case "file-menu-entry5": //watchlist
$get_array = array("db_select" => "watch_list", "db_tbl" => $db_tbl, "db_from" => "watchlist", "db_where" => "`usr_id`='" . $usr_id . "'", "db_fields" => "watch_list");
break;
case "file-menu-entry7": //file comments
$sql = sprintf("SELECT A.`c_id`, B.`usr_id` FROM `db_%scomments` A, `db_%sfiles` B WHERE A.`file_key`=B.`file_key` AND B.`usr_id`='%s';", $db_tbl, $db_tbl, $usr_id);
$rs = $db->execute($sql);
return $rs->recordcount();
break;
case "file-menu-entry8": //file responses
$sql = sprintf("SELECT
A.`file_responses`,
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'", $db_tbl, $db_tbl, $usr_id);
$rs = $db->execute($sql);
$t = $rs->recordcount();
$r = $rs->getrows();
$tt = 0;
for ($i = 0; $i < $t; $i++) {
$tt += count(unserialize($r[$i]["file_responses"]));
}
return $tt;
break;
default: //playlists
$get_array = array("db_select" => "pl_files", "db_tbl" => $db_tbl, "db_from" => "playlists", "db_where" => "`usr_id`='" . $usr_id . "' AND `pl_id`='" . (is_array($for) ? $for[1] : substr(self::$filter->clr_str($_GET["s"]), 21)) . "'", "db_fields" => "pl_files");
break;
}
$total = self::fileCountDB($get_array);
return $total;
}
/* get playlists types */
public function getPlTypes($id, $do_return = 1)
{
$cfg = self::$cfg;
$db = self::$db;
$language = self::$language;
$s = 0;
$pl_total = 0;
$usr_id = (int) $_SESSION["USER_ID"];
$for = array('live' => 'live', 'video' => 'video', 'short' => 'short', 'image' => 'image', 'audio' => 'audio', 'document' => 'doc', 'blog' => 'blog');
$html = '';
$html .= '';
$html .= '
';
if ($do_return == 1) {
return $html;
}
}
/* user playlists nav menu entries */
public function userPlaylists($for)
{
$cfg = self::$cfg;
if ($cfg["file_playlists"] == 0) {
return false;
}
return self::getPlTypes($for);
}
/* file settings contents */
public function fileSettingsHTM($type, $val, $readonly = false)
{
$language = self::$language;
switch ($type) {
case "option_title":
$opt_type = 1;
$label = $language["files.text.file.title"];
$info_array = array(0 => "file_title");
break;
case "option_descr":
$opt_type = 1;
$label = $language["files.text.file.descr"];
$info_array = array(0 => "file_descr");
break;
case "option_tags":
$opt_type = 1;
$label = $language["files.text.file.tags"];
$info_array = array(0 => "file_tags");
break;
case "option_stream_server":
$opt_type = 1;
$label = $language["files.text.stream.server"];
$info_array = array(0 => "stream_server", 1 => "readonly");
break;
case "option_stream_name":
$opt_type = 1;
$label = $language["files.text.stream.name"];
$info_array = array(0 => "stream_key", 1 => "readonly");
break;
case "option_categ":
$opt_type = 1;
$label = $language["files.text.file.categ"];
$info_array = array(0 => "file_category");
break;
case "option_privacy":
$opt_type = 2;
$lang_array = array("public" => $language["files.text.public"], "private" => $language["files.text.private"], "personal" => $language["files.text.personal"]);
break;
case "option_comments":
$opt_type = 2;
$lang_array = array("all" => $language["files.text.comments.auto"], "fronly" => $language["files.text.comments.fronly"], "approve" => $language["files.text.comments.approve"], "none" => $language["files.text.comments.none"]);
break;
case "option_votes":
$opt_type = 2;
$lang_array = array("1" => $language["files.text.comments.vote.all"], "0" => $language["files.text.comments.vote.none"]);
break;
case "option_spam":
$opt_type = 2;
$lang_array = array("1" => $language["files.text.comments.spam.all"], "0" => $language["files.text.comments.spam.none"]);
break;
case "option_responses":
$opt_type = 2;
$lang_array = array("all" => $language["files.text.responses.all"], "approve" => $language["files.text.responses.approve"], "none" => $language["files.text.responses.none"]);
break;
case "option_rating":
$opt_type = 2;
$lang_array = array("1" => $language["files.text.rating.all"], "0" => $language["files.text.rating.none"]);
break;
case "option_embed":
$opt_type = 2;
$lang_array = array("1" => $language["files.text.embed.all"], "0" => $language["files.text.embed.none"]);
break;
case "option_social":
$opt_type = 2;
$lang_array = array("1" => $language["files.text.social.share"], "0" => $language["files.text.social.none"]);
break;
case "option_chat":
$opt_type = 2;
$lang_array = array("1" => $language["files.text.live.chat"], "0" => $language["files.text.live.chat.none"]);
break;
case "option_vod":
$opt_type = 2;
$lang_array = array("1" => $language["files.text.live.vod"], "0" => $language["files.text.live.vod.none"]);
break;
case "option_thumbnail":
$opt_type = 2;
break;
}
switch ($opt_type) {
case "2":
$cls0 = 'bottom-border-only1';
$cls1 = 'file-option-trg';
$cls2 = 'ct-bullet-out';
$cls3 = 'no-display';
$cls4 = 'greyed-out';
break;
case "1":
$cls0 = 'no-bottom-border';
$cls1 = 'file-option-cls';
$cls2 = 'ct-bullet-in';
$cls3 = '';
$cls4 = 'bold';
break;
}
$ht_ct .= $opt_type == 1 ? self::fileSettingsInfo($info_array, $val) : self::fileSettingsTypes($type, $lang_array, $val);
$html .= '';
$html .= '
';
$html .= '';
$html .= '
';
$html .= '
' . $ht_ct . '
';
$html .= '
';
return $html;
}
/* html category select */
public function fileCategorySelect($for, $_ct_id = '', $db_id = 0)
{
include 'f_core/config.backend.php';
$db = self::$db;
$class_database = self::$dbc;
$class_filter = self::$filter;
switch ($for) {
case "file_edit":
$key = isset($_GET["l"]) ? 'l' . $class_filter->clr_str($_GET["l"]) : (isset($_GET["v"]) ? 'v' . $class_filter->clr_str($_GET["v"]) : (isset($_GET["i"]) ? 'i' . $class_filter->clr_str($_GET["i"]) : (isset($_GET["a"]) ? 'a' . $class_filter->clr_str($_GET["a"]) : (isset($_GET["d"]) ? 'd' . $class_filter->clr_str($_GET["d"]) : (isset($_GET["b"]) ? 'b' . $class_filter->clr_str($_GET["b"]) : (null))))));
$s_id = 'edit_category';
break;
case "upload":
$key = $class_filter->clr_str($_GET["t"]);
$key = $key == 'short' ? 'video' : $key;
$s_id = isset($_GET["u"]) ? 'upload_category_u' : 'upload_category';
break;
case "backend":
$key = $_ct_id[0];
$s_id = 'file_category';
break;
}
switch ($key[0]) {
case "l":$tbl = 'live';
break;
case "v":$tbl = 'video';
break;
case "s":$tbl = 'short';
break;
case "i":$tbl = 'image';
break;
case "a":$tbl = 'audio';
break;
case "d":$tbl = 'doc';
break;
case "b":$tbl = 'blog';
break;
}
$fortmp = $for;
$for = (strpos($_SERVER['REQUEST_URI'], $backend_access_url)) ? 'backend' : $for;
$ct_id = $for != 'backend' ? $class_database->singleFieldValue('db_' . $tbl . 'files', 'file_category', 'file_key', ($for == 'upload' ? $key : substr($key, 1))) : substr($_ct_id, 1);
$ct_name = $class_database->singleFieldValue('db_categories', 'ct_name', 'ct_id', $ct_id);
$ct = $db->execute(sprintf("SELECT `ct_id`, `ct_name`, `ct_lang` FROM `db_categories` WHERE `ct_type`='%s' AND `ct_active`='1' ORDER BY `ct_name` ASC;", $tbl));
$js = $for != 'backend' ? 'onchange="$(\'#input-loc\').val(this.value);$(\'#input-loc-tmp\').val(this.options[this.selectedIndex].text);"' : null;
$n = $for != 'backend' ? (isset($_GET["u"]) ? 'file_category_sel_u' : 'file_category_sel') : 'file_category_' . $db_id;
$ht .= '';
return $ht;
}
/* html file details (title, descr, tags, categ) */
public function fileSettingsInfo($info_array, $val)
{
$class_filter = self::$filter;
$ht_cls = null;
switch ($info_array[0]) {
case "stream_server":
$ro = $info_array[1] == 'readonly' ? 'readonly="readonly" onclick="this.select()"' : null;
$srv = VServer::getFreeServer('bcast');
$html = VGenerate::simpleDivWrap($ht_cls, '', '');
break;
case "stream_key":
$key = $class_filter->clr_str($_GET["l"]);
$hash1 = secured_encrypt($_SESSION["USER_ID"] . ':' . $_SESSION["USER_KEY"] . ':' . self::$cfg["global_salt_key"]);
$hash2 = strrev(md5($_SESSION["USER_ID"] . $_SESSION["USER_KEY"] . self::$cfg["global_salt_key"]));
$ro = $info_array[1] == 'readonly' ? 'readonly="readonly" onclick="this.select()"' : null;
$html = VGenerate::simpleDivWrap($ht_cls, '', '');
$html .= '';
$html .= VGenerate::simpleDivWrap($ht_cls, '', '');
break;
case "file_title":
$html = VGenerate::simpleDivWrap($ht_cls, '', '');
break;
case "file_descr":
$html = VGenerate::simpleDivWrap($ht_cls, '', '');
break;
case "file_tags":
$html = VGenerate::simpleDivWrap($ht_cls, '', '');
break;
case "file_category":
$html = VGenerate::simpleDivWrap('selector fe', '', self::fileCategorySelect('file_edit'));
break;
}
return $html;
}
/* html radio check options */
public function fileSettingsTypes($type, $lang_array, $val)
{
$class_filter = self::$filter;
$class_database = self::$dbc;
$cfg = self::$cfg;
$language = self::$language;
if ($type != 'option_thumbnail') {
foreach ($lang_array as $key => $vals) {
$html .= '
';
}
} elseif ($type == 'option_thumbnail' and $val[0] != 'i') {
$key = $class_filter->clr_str($_GET[$val[0]]);
$usr_key = $class_filter->clr_str($_SESSION["USER_KEY"]);
$thumb_server = $class_database->singleFieldValue('db_' . self::$type . 'files', 'thumb_server', 'file_key', $key);
$thumb_cache = $class_database->singleFieldValue('db_' . self::$type . 'files', 'thumb_cache', 'file_key', $key);
$thumb_cache = $thumb_cache > 1 ? $thumb_cache : null;
$thumbnail = '
';
$html .= VGenerate::simpleDivWrap('', '', $thumbnail);
$html .= VGenerate::simpleDivWrap('vs-column fifths-off update-button', '', '');
$js = '$(".thumb-popup").click(function(){';
$js .= 'var popupid = $(this).attr("rel");';
$js .= '$("#popuprel").mask(" ");';
$js .= '$("#popuprel").load("' . $cfg["main_url"] . '/' . VHref::getKey("files_edit") . '?fe=1&' . $val[0] . '=' . $key . '&do=thumb", function(){';
$js .= '$("#popuprel").unmask();';
$js .= '});';
$js .= '});';
$html .= VGenerate::declareJS('$(document).ready(function(){' . $js . '});');
}
return $html;
}
/* checks for saving */
public function saveEditCheck($post_arr, $cfg_arr)
{
foreach ($cfg_arr as $key => $val) {
if ($cfg_arr[$key] == 0) {
unset($post_arr[$key]);
}
}
unset($post_arr["file_title"]);
unset($post_arr["file_description"]);
unset($post_arr["file_tags"]);
unset($post_arr[(isset($_GET["u"]) ? 'file_category_sel_u' : 'file_category_sel')]);
unset($post_arr["stream_server"]);
unset($post_arr["stream_key"]);
unset($post_arr["stream_chat"]);
unset($post_arr["stream_vod"]);
return $post_arr;
}
/* insert media into blogs */
public static function blog_insertMedia()
{
$language = self::$language;
$cfg = self::$cfg;
$class_filter = self::$filter;
$db = self::$db;
$type = $class_filter->clr_str($_GET["t"]);
$bkey = $class_filter->clr_str($_GET["b"]);
$js = "$.fancybox.close(); if (typeof($('.blog-media-select li.thumb-selected').html()) != 'undefined') { tinymce.activeEditor.insertContent('[media_" . $type . "_'+$('.blog-media-select li.thumb-selected').attr('rel-key')+']'); }";
$html = '
' . str_replace('##TYPE##', $language["frontend.global." . $type[0]], $language["files.text.insert.url.type"]) . '
';
$ht_js = '(function() {[].slice.call(document.querySelectorAll(".tabs.pltabs")).forEach(function (el) {new CBPFWTabs(el);});})();';
$ht_js .= '
$(".find-url").on("click", function() {
url = current_url + menu_section + "?fe=1&b=' . $bkey . '&do=find&t=' . $type . '";
$(".fancybox-inner").mask(" ");
$.post(url, $(".entry-form-class").serialize(), function(data) {
$("#find-url-response").html(data);
$(".fancybox-inner").unmask();
});
});
$( "#bulletin-file" ).on( "keydown", function(event) {
if(event.which == 13) {
event.preventDefault();
$(".find-url").click();
}
});
';
$html .= VGenerate::declareJS('$(document).ready(function(){' . $ht_js . '});');
echo $html;
}
/* search by url for inserting into blogs */
public static function blog_findMedia()
{
$language = self::$language;
$cfg = self::$cfg;
$class_filter = self::$filter;
$class_database = self::$dbc;
$db = self::$db;
$type = $class_filter->clr_str($_GET["t"]);
$main_len = strlen($cfg["main_url"]);
/* checking file url */
$ch_file_url = $class_filter->clr_str($_POST["bulletin_file"]);
if (substr($ch_file_url, 0, $main_len) == $cfg["main_url"]) {
$url_arr = parse_url($ch_file_url);
if ($cfg["file_seo_url"] == 1) {
$a = explode("/", $url_arr["path"]);
$b = count($a);
$file_key = $a[$b - 2];
$tbl = $a[$b - 3];
$new_key = $tbl . "=" . $file_key;
} else {
$new_key = substr($url_arr["query"], 0, 18);
$new_info = explode("=", $new_key);
$tbl = $new_info[0];
$file_key = $new_info[1];
}
switch ($tbl) {
case "l":$db_tbl = 'live';
break;
case "v":$db_tbl = 'video';
break;
case "s":$db_tbl = 'short';
break;
case "i":$db_tbl = 'image';
break;
case "a":$db_tbl = 'audio';
break;
case "d":$db_tbl = 'doc';
break;
case "b":$db_tbl = 'blog';
break;
}
$m = $tbl == 'd' ? 'document' : $db_tbl;
if ($db_tbl != $type) {
echo '' . $language["frontend.global.results.none"] . '
';
exit;
}
$_uid = $class_database->singleFieldValue('db_' . $db_tbl . 'files', 'usr_id', 'file_key', $file_key);
$_sql = sprintf("SELECT
B.`usr_key`,
C.`thumb_server`, C.`thumb_cache`,
C.`file_title`
FROM
`db_accountuser` B, `db_%sfiles` C
WHERE
C.`usr_id`=B.`usr_id` AND
C.`file_key`='%s' AND
C.`privacy`%s AND
C.`approved`='1' AND
C.`deleted`='0' AND
C.`active`='1'
LIMIT 1;", $db_tbl, $file_key, ($_uid == $_SESSION["USER_ID"] ? "!='personal'" : "='public'"));
$dbc = $db->execute($_sql);
if ($cfg[$m . "_module"] == 1 and $_uid > 0 and $dbc->fields["usr_id"] == $_uid) {
$usr_key = $dbc->fields["usr_key"];
$thumb_server = $dbc->fields["thumb_server"];
$title = $dbc->fields["file_title"];
$thumb_cache = $dbc->fields["thumb_cache"];
$thumb_cache = $thumb_cache > 1 ? $thumb_cache : null;
$img_src = self::thumbnail(array($usr_key, $thumb_cache), $file_key, $thumb_server);
$thumbnail = '
';
$js = "$.fancybox.close(); if (typeof($('#find-url-response .vs-column').html()) != 'undefined') { tinymce.activeEditor.insertContent('[media_" . $db_tbl . "_" . $file_key . "]'); }";
echo $html = '
' . $thumbnail . '
' . $title . '
';
} else {
echo '' . $language["frontend.global.results.none"] . '
';
}
} else {
echo '' . $language["frontend.global.results.none"] . '
';
}
}
/* adding new blog */
public static function newBlog()
{
$language = self::$language;
$cfg = self::$cfg;
$for = self::$type;
$class_filter = self::$filter;
$class_database = self::$dbc;
$db = self::$db;
$blog_response = isset($_GET["r"]) ? true : false;
if ($cfg[$for . "_module"] == 1) {
if ($_POST) {
$title = $class_filter->clr_str($_POST["add_new_title"]);
$descr = $class_filter->clr_str($_POST["add_new_descr"]);
$tags = $class_filter->clr_str($_POST["add_new_tags"]);
$categ = (int) $_POST[(isset($_GET["u"]) ? "file_category_sel_u" : "file_category_sel")];
$usr_id = (int) $_SESSION["USER_ID"];
$usr_key = $class_filter->clr_str($_SESSION["USER_KEY"]);
$error = VUseraccount::checkPerm('upload', $for[0]);
$error = $cfg["paid_memberships"] == 1 ? VUpload::subscriptionCheck($for, '') : $error;
$error = $error != '' ? $error : ($title == '' ? $language["notif.error.required.field"] . $language["files.text.file.title"] : ($tags == '' ? $language["notif.error.required.field"] . $language["files.text.file.tags"] : ($categ == 0 ? $language["notif.error.required.field"] . $language["files.text.file.categ"] : false)));
if ($for == 'live') {
$sql = sprintf("SELECT `db_id`, `file_key` FROM `db_livefiles` WHERE `usr_id`='%s' AND `stream_ended`='0' AND `active`='1' AND `upload_date` > NOW() - INTERVAL 10 MINUTE LIMIT 1;", $usr_id);
$ss = $db->execute($sql);
if ($ss->fields["db_id"]) {
$error = $language["notif.error.live.exist"] . ' fields["file_key"] . '">' . $language["frontend.global.here"] . '.';
}
}
if ($error) {
echo VGenerate::noticeTpl('', $error, '');
} else {
$db_tbl_info = 'db_' . $for . 'files';
$fileext = ($for == 'live' ? 'live' : 'tplb');
$filekey = VUserinfo::generateRandomString(10);
$embedkey = VUserinfo::generateRandomString(10);
$db_approved = ($cfg["file_approval"] == 1 ? 0 : 1);
$v_info = array(
"usr_id" => $usr_id,
"file_key" => $filekey,
"old_file_key" => 0,
"file_type" => $fileext,
"file_name" => null,
"file_size" => null,
"upload_date" => date("Y-m-d H:i:s"),
"is_subscription" => (int) $cfg["paid_memberships"],
"file_views" => 0,
"file_comments" => 0,
"file_responses" => 0,
"file_like" => 0,
"file_dislike" => 0,
"embed_key" => $embedkey,
"file_title" => $title,
"file_description" => $descr,
"file_tags" => VForm::clearTag($tags),
"file_category" => $categ,
"approved" => $db_approved,
"privacy" => "public",
"comments" => "all",
"comment_votes" => 1,
"rating" => 1,
"responding" => "all",
"embedding" => 1,
"social" => 1,
);
$do_db = $class_database->doInsert($db_tbl_info, $v_info);
if ($db->Affected_Rows() > 0) {
/* file count */
$ct_update = $db->execute(sprintf("UPDATE `db_accountuser` SET `usr_%s_count`=`usr_%s_count`+1 WHERE `usr_id`='%s' LIMIT 1;", $for[0], $for[0], $usr_id));
/* activity */
$log = ($cfg["activity_logging"] == 1 and $action = new VActivity($usr_id, 0)) ? $action->addTo('log_upload', $for . ':' . $filekey) : null;
/* end if broadcast details */
if ($for == 'live') {
$_p = unserialize($class_database->singleFieldValue('db_accountuser', 'usr_perm', 'usr_id', $usr_id));
if ($_p["perm_upload_l"] == '1') {
$db->execute(sprintf("UPDATE `db_livefiles` SET `stream_key`='%s', `stream_key_active`='1', `stream_vod`='%s', `stream_chat`='%s', `file_duration`='1' WHERE `file_key`='%s' LIMIT 1;", md5($cfg["global_salt_key"] . $usr_id . SK_INC), $_p["perm_live_vod"], $_p["perm_live_chat"], $filekey));
}
$tmp_file = str_replace($cfg["main_url"], $cfg["main_dir"], VUseraccount::getProfileImage($usr_id, false));
if ($tmp_file && is_file($tmp_file)) {
$src_folder = $cfg["media_files_dir"] . '/' . $usr_key . '/t/' . $filekey . '/';
$conv = new VDocument();
$conv->log_setup($filekey, false);
if ($conv->createThumbs_ffmpeg($src_folder, '1', 320, 180, $filekey, $usr_key, $tmp_file)) {}
if ($conv->createThumbs_ffmpeg($src_folder, '0', 640, 360, $filekey, $usr_key, $tmp_file)) {}
}
if ($cfg["paid_memberships"] == 1) {
$filesize = 1024;
$sql = sprintf("UPDATE `db_packusers` SET `pk_usedspace`=`pk_usedspace`+%s, `pk_total_%s`=`pk_total_%s`+1 WHERE `usr_id`='%s' LIMIT 1;", $filesize, $for, $for, $usr_id);
$db_dub = $db->execute($sql);
}
$notify = VUpload::notifySubscribers(0, $for, $filekey, '', $usr_key); //notify admin
$js = '
window.location="' . $cfg["main_url"] . '/' . VHref::getKey("files_edit") . '?fe=1&l=' . $filekey . '";
$.fancybox.close();
';
echo VGenerate::declareJS($js);
return;
}
/* copy blog file */
$blog_file = $cfg["ww_templates_dir"] . '/tpl_page/tpl_blog.tpl';
$blog_tmb = $cfg["global_images_dir"] . '/default-blog.png';
if (is_file($blog_file)) {
$dst_file = $cfg["media_files_dir"] . '/' . $usr_key . '/b/' . $filekey . '.tplb';
$dst_dir = $cfg["media_files_dir"] . '/' . $usr_key . '/t/' . $filekey;
$dst_tmb = $dst_dir . '/1.jpg';
$dst_tmb_0 = $dst_dir . '/0.jpg';
if (copy($blog_file, $dst_file)) {
if (mkdir($dst_dir, 0777)) {
copy($blog_tmb, $dst_tmb);
copy($blog_tmb, $dst_tmb_0);
if (!$blog_response) {
$js = '
$.fancybox.close();
$("#file-search-button").click();
';
echo VGenerate::declareJS($js);
} else {
$responses = new VResponses;
VResponses::submitResponse(1, $filekey);
$js = '
$("#add-new-title-input").replaceWith("' . $title . '
");
$("#add-new-descr-input").replaceWith("' . $descr . '
");
$("#add-new-tags-input").replaceWith("' . $tags . '
");
$("#add-new-categ-input").replaceWith("' . $class_database->singleFieldValue('db_categories', 'ct_name', 'ct_id', $categ) . '
");
$(\'' . $language["frontend.global.click"] . ' ' . $language["respond.text.file.blog.e"] . '
\').insertAfter("#add-new-blog-response");
';
echo VGenerate::declareJS($js);
}
if ($cfg["paid_memberships"] == 1) {
$filesize = 1024;
$sql = sprintf("UPDATE `db_packusers` SET `pk_usedspace`=`pk_usedspace`+%s, `pk_total_%s`=`pk_total_%s`+1 WHERE `usr_id`='%s' LIMIT 1;", $filesize, $for, $for, $usr_id);
$db_dub = $db->execute($sql);
}
$notify = $db_approved == 1 ? VUpload::notifySubscribers($usr_id, $for, $filekey, '', $usr_key) : VUpload::notifySubscribers(0, $for, $filekey, '', $usr_key);
echo VGenerate::noticeTpl('', '', ($db_approved == 1 ? $language["respond.text.approved"] : $language["notif.success.request"]));
}
$js = '
window.location="' . $cfg["main_url"] . '/' . VHref::getKey("files_edit") . '?fe=1&b=' . $filekey . '&u";
$.fancybox.close();
';
echo VGenerate::declareJS($js);
}
} else {
echo VGenerate::noticeTpl('', $language["notif.error.invalid.request"], '');
}
}
}
} else {
$isv = $class_database->singleFieldValue('db_accountuser', 'usr_verified', 'usr_id', (int) $_SESSION["USER_ID"]);
if ($isv == 0) {
echo VGenerate::declareJS('window.location="' . $cfg["main_url"] . '/' . VHref::getKey("upload") . '?t=video";');
exit;
}
$categ = VGenerate::simpleDivWrap('selector fe', '', self::fileCategorySelect('upload'));
$html = '
';
$html .= '';
echo $html;
}
}
}
/* lists of files to insert into blogs */
private static function blog_mediaList($type = false, $favorites = false)
{
$language = self::$language;
$cfg = self::$cfg;
$for = !$type ? self::$type : $type;
$class_filter = self::$filter;
$db = self::$db;
$uid = (int) $_SESSION["USER_ID"];
$html = null;
$fk = array();
if ($favorites) {
$q = " AND A.`usr_id`='0' ";
$fsql = sprintf("SELECT `db_id`, `file_key` FROM `db_%sfavorites` WHERE `usr_id`='%s';", $for, $uid);
$frs = $db->execute($fsql);
if ($frs->fields["db_id"] != '') {
while (!$frs->EOF) {
$fk[] = $frs->fields["file_key"];
$frs->MoveNext();
}
}
if (isset($fk[0])) {
$q = sprintf(" AND A.`file_key` IN (%s)", implode(",", $fk));
}
}
$sql = sprintf("SELECT
A.`thumb_server`, A.`thumb_cache`, A.`file_key`, A.`file_title`, D.`usr_key`
FROM
`db_%sfiles` A, `db_accountuser` D
WHERE
A.`usr_id`=D.`usr_id` AND
A.`privacy`!='personal' AND
A.`active`='1' AND
A.`approved`='1' AND
A.`deleted`='0' AND
A.`usr_id`='%s'
%s
GROUP BY A.`file_key`;", $for, (int) $_SESSION["USER_ID"], $q);
$rs = $db->execute($sql);
if ($rs->fields["file_key"]) {
$s = 1;
$html .= '';
while (!$rs->EOF) {
$title = $rs->fields["file_title"];
$file_key = $rs->fields["file_key"];
$usr_key = $rs->fields["usr_key"];
$thumb_server = $rs->fields["thumb_server"];
$thumb_cache = $rs->fields["thumb_cache"];
$thumb_cache = $thumb_cache > 1 ? $thumb_cache : null;
$img_src = self::thumbnail(array($usr_key, $thumb_cache), $file_key, $thumb_server);
$thumbnail = '
';
$html .= '- ' . $thumbnail . '
';
$rs->MoveNext();
$s += 1;
}
$html .= '
';
} else {
$html .= '' . $language["frontend.global.results.none"] . '
';
}
return $html;
}
/* saving edited info */
public function saveEdit()
{
$language = self::$language;
$cfg = self::$cfg;
$for = self::$type;
$class_filter = self::$filter;
$db = self::$db;
$file_key = $class_filter->clr_str($_GET[$for[0]]);
$form_fields = VArraySection::getArray('edit_file');
$allowedFields = $form_fields[1];
$requiredFields = $form_fields[2];
$error_message = VForm::checkEmptyFields($allowedFields, $requiredFields);
$notice_message = '';
$u = 0;
if ($error_message == '') {
if ($for[0] == 'b' and $cfg["blog_module"] == 1 and isset($_POST["blog_html"])) {
$usr_key = $class_filter->clr_str($_SESSION["USER_KEY"]);
$blog_tpl = $cfg["media_files_dir"] . '/' . $usr_key . '/b/' . $file_key . '.tplb';
$blog_html = urldecode($_POST["blog_html"]);
if (!is_file($blog_tpl)) {
touch($blog_tpl);
}
if (is_file($blog_tpl)) {
if (file_put_contents($blog_tpl, $blog_html)) {
$u = 1;
}
}
}
$array_check = array(
"privacy" => $cfg["file_privacy"],
"comments" => $cfg["file_comments"],
"comment_votes" => $cfg["file_comment_votes"],
"comment_spam" => $cfg["file_comment_spam"],
"rating" => $cfg["file_rating"],
"responding" => $cfg["file_responses"],
"embedding" => $cfg["file_embedding"],
"social" => $cfg["file_social_sharing"],
);
$file_tags = VForm::clearTag($form_fields[0]["file_tags"]);
$allowed_meta = array("file_title" => $form_fields[0]["file_title"], "file_description" => $form_fields[0]["file_description"], "file_tags" => $file_tags, "file_category" => $form_fields[0]["file_category"]);
if ($for[0] == 'l') {
$_perm = unserialize(self::$dbc->singleFieldValue('db_accountuser', 'usr_perm', 'usr_id', (int) $_SESSION["USER_ID"]));
$_chat = ($cfg["live_chat"] == 1 and $_perm["perm_live_chat"] == 1) ? $form_fields[0]["stream_chat"] : 0;
$_vod = ($cfg["live_vod"] == 1 and $_perm["perm_live_vod"] == 1) ? $form_fields[0]["stream_vod"] : 0;
$allowed_live = array("stream_chat" => $_chat, "stream_vod" => $_vod);
}
$allowed_perm = self::saveEditCheck($form_fields[0], $array_check);
foreach ($allowed_meta as $key => $val) {
$q .= sprintf("C.`%s`='%s', ", $key, $val);
}
foreach ($allowed_perm as $key => $val) {
$q .= sprintf("C.`%s`='%s', ", $key, $val);
}
if ($for[0] == 'l' and is_array($allowed_live)) {
foreach ($allowed_live as $key => $val) {
$q .= sprintf("C.`%s`='%s', ", $key, $val);
}
}
$sql_loop = substr($q, 0, -2);
$sql = sprintf("UPDATE `db_%sfiles` C SET %s WHERE C.`usr_id`='%s' AND C.`file_key`='%s';", $for, $sql_loop, (int) $_SESSION["USER_ID"], $file_key);
$db_do = $db->execute($sql);
if ($db->Affected_Rows() > 0) {
$notice_message = $language["notif.success.request"];
echo VGenerate::declareJS('$("h1").html("' . $allowed_meta["file_title"] . '"); $("input[name=\"file_tags\"]").val("' . $file_tags . '");');
}
$notice_message = ($db->Affected_Rows() > 0 or $u > 0) ? $language["notif.success.request"] : null;
}
echo $html = ($error_message != '' or $notice_message != '') ? VGenerate::noticeTpl('', $error_message, $notice_message) : null;
}
/* editing files layout */
public function fileEdit()
{
$cfg = self::$cfg;
$language = self::$language;
$class_database = self::$dbc;
$class_filter = self::$filter;
$db = self::$db;
$p = VPlayers::playerInit('edit');
$_id = $p[0];
$_width = $p[1];
$_height = $p[2];
$usr_key = $class_filter->clr_str($_SESSION["USER_KEY"]);
$type = self::$type;
$file_key = $class_filter->clr_str($_GET[$type[0]]);
$usr_id = (int) $_SESSION["USER_ID"];
$_perm = unserialize(self::$dbc->singleFieldValue('db_accountuser', 'usr_perm', 'usr_id', $usr_id));
$sql = sprintf("SELECT
C.`file_title`, C.`file_description`, C.`file_tags`,
C.`privacy`, C.`comments`, C.`comment_votes`, C.`comment_spam`, C.`rating`, C.`responding`, C.`embedding`, C.`social`, C.`approved`,
C.`stream_server`, C.`stream_key`, C.`stream_live`, C.`stream_ended`, C.`stream_chat`, C.`stream_vod`, C.`file_comments`, C.`file_like`, C.`file_dislike`, C.`file_views`, C.`file_hd`, C.`file_name`, C.`file_size`, C.`last_viewdate`, C.`upload_date`, %s
D.`usr_id`, D.`usr_key`
FROM
`db_%sfiles` C, `db_accountuser` D
WHERE
C.`usr_id`=D.`usr_id` AND
C.`file_key`='%s' AND
C.`usr_id`='%s' AND
D.`usr_key`='%s' LIMIT 1;", ($type ? "C.`embed_key`, C.`embed_src`," : null), $type, $file_key, $usr_id, $usr_key);
$res = $db->execute($sql);
$usr_key = $res->fields["usr_key"];
$pl_ht = null;
$about_html = null;
$thumb_html = null;
$privacy_html = null;
$comm_html = null;
$commv_html = null;
$comms_html = null;
$rate_html = null;
$response_html = null;
$embed_html = null;
$social_html = null;
$views_html = null;
$live_html = null;
if ($res->fields["file_title"] == '' or $res->fields["usr_key"] == '') {
return $html = VGenerate::noticeTpl('', str_replace('##TYPE##', $language["frontend.global." . $type[0] . ".c"], $language["files.text.notfound"]), '');
}
if ($type[0] == 'b') {
$blog_tpl = $cfg["media_files_dir"] . '/' . $usr_key . '/b/' . $file_key . '.tplb';
$blog_html = is_file($blog_tpl) ? file_get_contents($blog_tpl) : null;
}
// about html
$about_html .= '
';
$about_html .= VGenerate::declareJS('$(function(){SelectList.init("' . (isset($_GET["u"]) ? 'file_category_sel_u' : 'file_category_sel') . '");});');
if ($type[0] == 'l') {
//live html
$chat_key = md5($file_key . (int) $_SESSION["USER_ID"] . (int) $_SESSION["USER_ID"] . $_SESSION["USER_NAME"] . VServer::get_remote_ip() . $cfg["live_chat_salt"]);
$chat_url = VServer::getFreeServer('chat') . '/' . VHref::getKey("chat") . '/' . $chat_key . '/' . $file_key;
$live_html .= '';
if ($res->fields["stream_ended"] == '0') {
$live_js .= 'aa = "' . $cfg["live_server"] . '"; bb = "' . $cfg["live_cast"] . '";';
$live_js .= '$(".icheck-box input[name=option_vod]:first").on("ifChecked", function(event){if ($(this).is(":checked")) $("input[name=files_text_stream_server]").val(aa); });';
$live_js .= '$(".icheck-box input[name=option_vod]:first").on("ifUnchecked", function(event){if (!$(this).is(":checked")) $("input[name=files_text_stream_server]").val(bb); });';
$live_html .= VGenerate::declareJS('$(document).ready(function(){' . $live_js . '});');
}
}
if ($cfg["file_thumb_change"] == 1 and $type[0] != 'i') {
//thumb html
$thumb_html .= '';
}
if ($cfg["file_privacy"] == 1) {
//privacy html
$privacy_html .= '';
}
if ($cfg["file_comments"] == 1) {
//comments html
$comm_html .= '';
}
if ($cfg["file_comment_votes"] == 1) {
//comment votes html
$commv_html .= '';
}
if ($cfg["file_comment_spam"] == 1) {
//comment spam votes html
$comms_html .= '';
}
if ($cfg["file_rating"] == 1) {
//rating html
$rate_html .= '';
}
if ($cfg["file_responses"] == 1) {
//responses html
$response_html .= '';
}
if ($cfg["file_embedding"] == 1) {
//embed html
$embed_html .= '';
}
if ($cfg["file_social_sharing"] == 1) {
//social sharing html
$social_html .= '';
}
if ($cfg["affiliate_module"] == 1) {
//views html
$views_html .= '';
}
$btn_text = ($type[0] == 'l' and $res->fields["stream_ended"] == 0 and $res->fields["stream_live"] == 0) ? $language["frontend.global.publish.live"] : $language["frontend.global.saveupdate"];
$html = '
' . $res->fields["file_title"] . '
' . ($type[0] == 'l' ? '
' : null) . '
' . ('
') . '
' . ($type[0] == 'b' ? '
' : null) . '
' . (($cfg["file_thumb_change"] == 1 and $type[0] != 'i') ? '
' : null) . '
' . ($cfg["file_privacy"] == 1 ? '
' : null) . '
' . ($cfg["file_comments"] == 1 ? '
' : null) . '
' . ($cfg["file_comment_votes"] == 1 ? '
' : null) . '
' . ($cfg["file_comment_spam"] == 1 ? '
' : null) . '
' . ($cfg["file_rating"] == 1 ? '
' : null) . '
' . ($cfg["file_responses"] == 1 ? '
' : null) . '
' . ($cfg["file_embedding"] == 1 ? '
' : null) . '
' . ($cfg["file_social_sharing"] == 1 ? '
' : null) . '
' . ($res->fields["approved"] == 0 ? VGenerate::noticeTpl('', str_replace('##TYPE##', $language["frontend.global." . $type[0]], $language["files.text.pending.appr"]), '') : null) . '
' . ($type[0] == 'l' ? '
' : null) . '
' . ($type[0] == 'b' ? '
' . $language["files.option.blog"] . '
' : null) . '
' . (($cfg["file_thumb_change"] == 1 and $type[0] != 'i') ? '
' . $language["files.option.thumb"] . '
' . $thumb_html . '
' : null) . '
' . ($cfg["file_privacy"] == 1 ? '
' . $language["files.option.privacy"] . '
' . $privacy_html . '
' : null) . '
' . ($cfg["file_comments"] == 1 ? '
' . $language["files.option.comments"] . '
' . $comm_html . '
' : null) . '
' . ($cfg["file_comment_votes"] == 1 ? '
' . $language["files.option.comment.vote"] . '
' . $commv_html . '
' : null) . '
' . ($cfg["file_comment_spam"] == 1 ? '
' . $language["files.option.comment.spam"] . '
' . $comms_html . '
' : null) . '
' . ($cfg["file_rating"] == 1 ? '
' . $language["files.option.rating"] . '
' . $rate_html . '
' : null) . '
' . ($cfg["file_responses"] == 1 ? '
' . $language["files.option.video.response"] . '
' . $response_html . '
' : null) . '
' . ($cfg["file_embedding"] == 1 ? '
' . $language["files.option.embed"] . '
' . $embed_html . '
' : null) . '
' . ($cfg["file_social_sharing"] == 1 ? '
' . $language["files.option.social.share"] . '
' . $social_html . '
' : null) . '
';
$html .= '
';
$html .= VGenerate::declareJS('$(document).ready(function(){' . $ht_js . '});');
return $html;
}
/* changing thumb image, uploading */
public function thumbChange_upload()
{
$cfg = self::$cfg;
$class_filter = self::$filter;
$language = self::$language;
echo '1'; //the weirdest fix EVER, but jquery form plugin fails without it...
$type = self::$type;
$key = $class_filter->clr_str($_GET[$type[0]]);
$upload_file_name = $class_filter->clr_str($_FILES["fedit_image"]["tmp_name"]);
$upload_file_size = intval($_FILES["fedit_image"]["size"]);
$upload_file_limit = 2 * 1024 * 1024;
$upload_file_type = strtoupper(VFileinfo::getExtension($_FILES["fedit_image"]["name"]));
$upload_allowed = explode(',', strtoupper('gif,jpeg,jpg,png'));
$error_message = $upload_file_size > $upload_file_limit ? $language["account.error.filesize"] : null;
$error_message = ($error_message == '' and !in_array($upload_file_type, $upload_allowed)) ? $language["account.error.allowed"] : $error_message;
if ($error_message == '') {
if (strpos($upload_file_name, '.php') !== false or strpos($upload_file_name, '.pl') !== false or strpos($upload_file_name, '.asp') !== false or strpos($upload_file_name, '.htm') !== false or strpos($upload_file_name, '.cgi') !== false or strpos($upload_file_name, '.py') !== false or strpos($upload_file_name, '.sh') !== false or strpos($upload_file_name, '.cin') !== false) {
$error_message = $language["account.error.allowed"];
}
}
echo $show_error = $error_message != '' ? VGenerate::noticeTpl('', $error_message, '') : null;
if ($error_message == '') {
$ukey = $class_filter->clr_str($_SESSION["USER_KEY"]);
$mdir = $cfg["media_files_dir"];
$tmp_file = $mdir . '/' . $ukey . '/t/' . $key . '/tmp_src.jpg';
$_file = $mdir . '/' . $ukey . '/t/' . $key . '/tmp_1.jpg';
$tmp_img = $cfg["media_files_url"] . '/' . $ukey . '/t/' . $key . '/tmp_src.jpg';
if (is_file($tmp_file)) {
@unlink($tmp_file);
}
if (rename($upload_file_name, $tmp_file)) {
$src_folder = $cfg["media_files_dir"] . '/' . $ukey . '/t/' . $key . '/';
switch ($type[0]) {
case "l":
case "v":
case "a":
case "d":
case "b":
case "s":
$class = "VDocument";
$short = $type[0] == 's';
if ($tmp_file && is_file($tmp_file)) {
$conv = new $class();
$conv->log_setup($key, false);
if ($conv->createThumbs_ffmpeg($src_folder, 'tmp_1', 640, 360, $key, $ukey, $tmp_file, $short)) {
}
}
break;
case "i":break;
}
}
if (filesize($tmp_file) > 0) {
chmod($tmp_file, 0644);
$image_replace = '';
$input_replace = '$("#overview-userinfo-file").replaceWith("' . $image_replace . '");';
echo $do_replace = $error_message == '' ? VGenerate::declareJS('$(document).ready(function(){' . $input_replace . '});') : null;
}
}
}
/* get thumb cache nr */
public static function thumb_cache($type, $file_key, $plus = 0)
{
global $db, $cfg, $class_filter;
$type = $class_filter->clr_str($type);
$file_key = (int) $file_key;
$usr_id = (int) $_SESSION["USER_ID"];
$sql = sprintf("SELECT `thumb_cache` FROM `db_%sfiles` WHERE `file_key`='%s'%s LIMIT 1;", $type, $file_key, ($usr_id > 0 ? " AND `usr_id`='" . $usr_id . "'" : null));
$tmb = $db->execute($sql);
$thumb_cache = ((int) $tmb->fields["thumb_cache"]) + (int) $plus;
return ($thumb_cache > 1 ? $thumb_cache : null);
}
/* save changed thumbnail image */
public function thumbChange_save()
{
$db = self::$db;
$cfg = self::$cfg;
$class_filter = self::$filter;
$class_database = self::$dbc;
if ($_POST) {
$key = $class_filter->clr_str($_GET[$_POST["fedit_image_temp"]]);
$user_key = $class_filter->clr_str($_SESSION["USER_KEY"]);
$image_from = $class_filter->clr_str($_POST["fedit_image_action"]);
switch ($image_from) {
case "new":
$tcache = self::thumb_cache(self::$type, $key, 1);
$tmp_src = $cfg["media_files_dir"] . '/' . $user_key . '/t/' . $key . '/tmp_src.jpg';
$tmp_file = $cfg["media_files_dir"] . '/' . $user_key . '/t/' . $key . '/tmp_1.jpg';
$dst_file = $cfg["media_files_dir"] . '/' . $user_key . '/t/' . $key . '/1' . $tcache . '.jpg';
$dst_url = $cfg["media_files_url"] . '/' . $user_key . '/t/' . $key . '/0' . $tcache . '.jpg';
if (is_file($tmp_file) and rename($tmp_file, $dst_file)) {
$_file0 = $cfg["media_files_dir"] . '/' . $user_key . '/t/' . $key . '/0' . $tcache . '.jpg';
$src_folder = $cfg["media_files_dir"] . '/' . $user_key . '/t/' . $key . '/';
switch (self::$type[0]) {
case "l":
case "v":
case "s":
case "a":
case "d":
case "b":
$class = "VDocument";
$short = self::$type[0] == 's';
if ($tmp_src && is_file($tmp_src)) {
$conv = new $class();
$conv->log_setup($key, false);
$conv->createThumbs_ffmpeg($src_folder, 0 . $tcache, 640, 360, $key, $user_key, $tmp_src, $short);
if ($conv->createThumbs_ffmpeg($src_folder, 1 . $tcache, 320, 240, $key, $user_key, $tmp_src, $short)) {
$sql = sprintf("SELECT `thumb_server`, `embed_src` FROM `db_%sfiles` WHERE `file_key`='%s' LIMIT 1;", self::$type, $key);
$get = $db->execute($sql);
$src = $get->fields["embed_src"];
$tmb_id = $get->fields["thumb_server"];
if ($tmb_id > 0) {
$send_thumbs = $src == 'local' ? 1 : 2;
$cmd = sprintf("%s %s/f_modules/m_frontend/m_file/transfer.php %s %s %s %s %s", '/usr/local/bin/php', $cfg["main_dir"], self::$type, $key, $user_key, $tmb_id, $send_thumbs);
exec(escapeshellcmd($cmd) . ' >/dev/null &');
}
}
}
break;
case "i":break;
}
@unlink($tmp_src);
echo VGenerate::declareJS('$("#option_thumbnail img.mediaThumb").replaceWith("
"); $(".fancybox-overlay.fancybox-overlay-fixed").hide().detach();');
} else {
echo VGenerate::noticeTpl('', 'No file selected', '');
}
break;
case "default":
$type = self::$type;
$key = $class_filter->clr_str($_GET[$type[0]]);
$tcache = self::thumb_cache(self::$type, $key, 1);
$src_folder = $cfg["media_files_dir"] . '/' . $user_key . '/t/' . $key . '/';
switch ($type[0]) {
case "a":$src = $cfg["global_images_dir"] . '/audio.png';
break;
case "b":$src = $cfg["global_images_dir"] . '/default-blog.png';
break;
case "d":$src = $cfg["global_images_dir"] . '/document.gif';
break;
case "l":$src = $cfg["global_images_dir"] . '/default-live.png';
break;
}
$dst0 = $cfg["media_files_dir"] . '/' . $user_key . '/t/' . $key . '/0' . $tcache . '.jpg';
$dst1 = $cfg["media_files_dir"] . '/' . $user_key . '/t/' . $key . '/1' . $tcache . '.jpg';
switch ($type[0]) {
case "v":
case "s":
$class = "VVideo";
$gs = md5($cfg["global_salt_key"] . $key);
$file_name_360p = $gs . '.360p.mp4';
$file_name_480p = $gs . '.480p.mp4';
$file_name_720p = $type[0] == 's' ? $gs . '.short.mp4' : $gs . '.720p.mp4';
$src_folder = $cfg["media_files_dir"] . '/' . $user_key . '/v/';
$src_360p = $src_folder . $file_name_360p;
$src_480p = $src_folder . $file_name_480p;
$src_720p = $src_folder . $file_name_720p;
$src = is_file($src_720p) ? $src_720p : (is_file($src_480p) ? $src_480p : (is_file($src_360p) ? $src_360p : false));
$cfg[] = $class_database->getConfigurations('thumbs_nr,log_video_conversion,thumbs_method');
$cfg["thumbs_method"] = 'rand';
if ($src && is_file($src)) {
$conv = new $class();
$fn = $type[0] == 's' ? 'extract_thumbs_short' : 'extract_thumbs';
if ($conv->load($src)) {
$conv->log_setup($key, false);
$conv->$fn(array($src, 'thumb'), $key, $user_key, null, 1); //large thumb
$conv->$fn($src, $key, $user_key, null, 1); //small
}
}
break;
case "a":
case "b":
case "d":
case "l":
$class = "VDocument";
if ($src && is_file($src)) {
$conv = new $class();
$conv->log_setup($key, false);
if ($conv->createThumbs_ffmpeg($src_folder, 1 . $tcache, 320, 200, $key, $user_key, $src)) {
}
if ($conv->createThumbs_ffmpeg($src_folder, 0 . $tcache, 640, 360, $key, $user_key, $src)) {
}
}
break;
case "i":break;
}
$dst_file = $cfg["media_files_dir"] . '/' . $user_key . '/t/' . $key . '/0' . $tcache . '.jpg';
$dst_url = $cfg["media_files_url"] . '/' . $user_key . '/t/' . $key . '/0' . $tcache . '.jpg';
echo VGenerate::declareJS('$("#option_thumbnail img.mediaThumb").replaceWith("
"); $(".fancybox-overlay.fancybox-overlay-fixed").hide().detach();');
break;
}
if ($tcache and is_file($dst_file)) {
$db->execute(sprintf("UPDATE `db_%sfiles` SET `thumb_cache`=`thumb_cache`+1 WHERE `file_key`='%s' AND `usr_id`='%s' LIMIT 1;", self::$type, $key, $_SESSION["USER_ID"]));
if ($db->Affected_Rows()) {
$old_index = $tcache - 1;
$old_index = $old_index > 1 ? $old_index : null;
$old_file_0 = $cfg["media_files_dir"] . '/' . $user_key . '/t/' . $key . '/0' . $old_index . '.jpg';
$old_file_1 = $cfg["media_files_dir"] . '/' . $user_key . '/t/' . $key . '/1' . $old_index . '.jpg';
$old_file_2 = $cfg["media_files_dir"] . '/' . $user_key . '/t/' . $key . '/2' . $old_index . '.jpg';
$old_file_3 = $cfg["media_files_dir"] . '/' . $user_key . '/t/' . $key . '/3' . $old_index . '.jpg';
if (is_file($old_file_0)) {
unlink($old_file_0);
}
if (is_file($old_file_1)) {
unlink($old_file_1);
}
if (is_file($old_file_2)) {
unlink($old_file_2);
}
if (is_file($old_file_3)) {
unlink($old_file_3);
}
}
}
}
}
/* cancel changing thumbnail */
public function thumbChange_cancel()
{
$cfg = self::$cfg;
$class_filter = self::$filter;
if ($_POST) {
$tmp_file = $class_filter->clr_str($_POST["fedit_image_temp"]);
$tmp_get = $class_filter->clr_str($_GET[$tmp_file]);
$ukey = $class_filter->clr_str($_SESSION["USER_KEY"]);
$mdir = $cfg["media_files_dir"];
$tmp_path_1 = $mdir . '/' . $ukey . '/t/' . $tmp_get . '/tmp_src.jpg';
$tmp_path_2 = $mdir . '/' . $ukey . '/t/' . $tmp_get . '/tmp_0.jpg';
$tmp_path_3 = $mdir . '/' . $ukey . '/t/' . $tmp_get . '/tmp_1.jpg';
if (is_file($tmp_path_1)) {
@unlink($tmp_path_1);
}
if (is_file($tmp_path_2)) {
@unlink($tmp_path_2);
}
if (is_file($tmp_path_3)) {
@unlink($tmp_path_3);
}
}
}
}
' . $text . '