clr_str($_SERVER["REQUEST_URI"]); if ($section == '' or $section == $href["channel"]) { $c = self::$db_cache ? $cfg['cache_view_user_id'] : false; // if (strpos($adr, $href["channels"]) !== false) { // $param = array_pop(explode($href["channel"], str_replace($href["channels"], '---', $adr))); // } else { // $param = array_pop(explode($href["channel"], $adr)); // } // generate error on purpose with WHERE `usr_name` and make sure it doesn't get indexed in meta tags (DONE) // might also need to search in depth in tpl files for the old channel url !!!!!! //search tpls for {href_entry key="channel"} and {href_entry key='channel'} $e = array_values(array_filter(explode('/', trim($adr)))); $key = $class_filter->clr_str(strstr($e[0], '?', true)); $key = explode('?', $e[0]); if ($key[0][0] == '@') { $name = $class_filter->clr_str(str_replace('@', '', $key[0])); $sql = sprintf("SELECT `usr_id`, `usr_key` FROM `db_accountuser` WHERE `usr_user`='%s' LIMIT 1;", $name); $rs = self::$db_cache ? $db->cacheExecute($c, $sql) : $db->execute($sql); if ($user_id = $rs->fields["usr_id"]) { $key = $rs->fields["usr_key"]; $mi = count($e) - 1; $module = $mi > 1 ? $e[$mi] : $e[1]; $m = explode('?', $module); $module = $m[0]; } } else { $key = explode('?', $e[2]); $name = $class_filter->clr_str($key[0]); $user_id = $class_database->singleFieldValue('db_accountuser', 'usr_id', 'usr_user', $name); if ($user_id) { header("Location: " . $cfg["main_url"] . '/@' . $name); exit; } else { header('Location: /error'); exit; } } if ($user_id > 0) { self::$user_id = (int) $user_id; self::$user_key = $key; self::$module = $module; self::$valid = true; $guest_chk = (int) $_SESSION["USER_ID"] == 0 ? VHref::guestPermissions('guest_browse_channel', '@' . $name) : null; $smarty->assign('channel_module', $module); $smarty->assign('channel_key', $key); $smarty->assign('usr_id', self::$user_id); if ($module == VHref::getKey("broadcasts") or $module == VHref::getKey("videos") or $module == VHref::getKey("shorts") or $module == VHref::getKey("images") or $module == VHref::getKey("audios") or $module == VHref::getKey("documents")) { $smarty->assign('c_section', VHref::getKey("browse")); // $smarty->assign('c_section', $module); } elseif ($module == VHref::getKey("blogs")) { $smarty->assign('c_section', VHref::getKey("blogs")); } elseif ($module == VHref::getKey("playlists")) { $smarty->assign('c_section', VHref::getKey("files")); } else { $smarty->assign('c_section', VHref::getKey("channel")); } $c = self::$db_cache ? $cfg['cache_channel_ch_cfg'] : false; $sql = sprintf("SELECT `ch_cfg`, `ch_photos`, `ch_photos_nr`, `ch_links`, `ch_channels`, `ch_title`, `ch_descr`, `ch_tags`, `ch_views`, `usr_partner`, `usr_affiliate`, `affiliate_badge`, `usr_joindate`, `usr_user`, `usr_dname`, `usr_subcount`, `usr_followcount`, `usr_v_count` FROM `db_accountuser` WHERE `usr_id`='%s' AND `usr_status`='1' LIMIT 1;", self::$user_id); $rs = self::$db_cache ? $db->cacheExecute($c, $sql) : $db->execute($sql); self::$user_name = $rs->fields["usr_user"]; $smarty->assign('usr_user', self::$user_name); self::$display_name = $rs->fields["usr_dname"]; self::$usr_affiliate = $rs->fields["usr_affiliate"]; self::$usr_partner = $rs->fields["usr_partner"]; self::$affiliate_badge = $rs->fields["affiliate_badge"]; self::$usr_subcount = $rs->fields["usr_subcount"]; self::$usr_followcount = $rs->fields["usr_followcount"]; self::$usr_v_count = $rs->fields["usr_v_count"]; self::$ch_cfg = unserialize($rs->fields["ch_cfg"]); self::$ch_photos = unserialize($rs->fields["ch_photos"]); self::$ch_links = unserialize($rs->fields["ch_links"]); self::$ch_channels = unserialize($rs->fields["ch_channels"]); self::$ch_photos_nr = (int) $rs->fields["ch_photos_nr"]; self::$ch_cfg["ch_title"] = $rs->fields["ch_title"]; self::$ch_cfg["ch_descr"] = $rs->fields["ch_descr"]; self::$ch_cfg["ch_tags"] = $rs->fields["ch_tags"]; self::$ch_cfg["ch_views"] = $rs->fields["ch_views"]; self::$ch_cfg["ch_join"] = $rs->fields["usr_joindate"]; self::$channel_name = (self::$ch_cfg["ch_title"] != '' ? self::$ch_cfg["ch_title"] : (self::$display_name != '' ? self::$display_name : self::$user_name)); if (!isset(self::$ch_cfg["ch_m_shorts"])) { self::$ch_cfg["ch_m_shorts"] = 1; } } } elseif ($section == $href["manage_channel"]) { $c = self::$db_cache ? $cfg['cache_channel_ch_cfg'] : false; $sql = sprintf("SELECT `ch_cfg`, `ch_photos`, `ch_photos_nr` FROM `db_accountuser` WHERE `usr_id`='%s' LIMIT 1;", self::getUserID()); $rs = self::$db_cache ? $db->execute($c, $sql) : $db->execute($sql); self::$ch_cfg = unserialize($rs->fields["ch_cfg"]); self::$ch_photos = unserialize($rs->fields["ch_photos"]); self::$ch_photos_nr = (int) $rs->fields["ch_photos_nr"]; self::$user_id = self::getUserID(); self::$user_key = $class_filter->clr_str($_SESSION["USER_KEY"]); self::$channel_name = $_SESSION["USER_DNAME"] != '' ? $class_filter->clr_str($_SESSION["USER_DNAME"]) : $class_filter->clr_str($_SESSION["USER_NAME"]); if (!isset(self::$ch_cfg["ch_m_shorts"])) { self::$ch_cfg["ch_m_shorts"] = 1; } } } /* layout for channel page */ public static function channelLayout() { $cfg = self::$cfg; $ch_cfg = self::$ch_cfg; $ch_links = self::$ch_links; $language = self::$language; $class_database = self::$dbc; $ch_photos = self::$ch_photos; $session_id = self::getUserID(); $channel_url = VHref::channelURL(["username" => self::$user_name]); if (!self::$valid) { header("Location: /404"); exit; // return VGenerate::noticeTpl('', $language["notif.error.invalid.request"], ''); } if ($ch_cfg["ch_visible"] == 0) { return VGenerate::noticeTpl('', $language["channel.offline.message"], ''); } $visitor_html = '
' . str_replace(array('##SIGNIN##', '##SIGNUP##'), array('' . self::$language["frontend.global.signin"] . '', '' . self::$language["frontend.global.createaccount"] . ''), self::$language["view.files.use.please"]) . '
'; /* user follows status */ if ($cfg["user_follows"] == 1) { /* $sql = sprintf("SELECT A.`follower_id`, B.`usr_followcount` FROM `db_followers` A, `db_accountuser` B WHERE A.`usr_id`=B.`usr_id` AND A.`usr_id`='%s' LIMIT 1;", self::$user_id); $rs = self::$db_cache ? self::$db->CacheExecute(self::$cfg['cache_view_sub_id'], $sql) : self::$db->execute($sql); $sub = $rs->fields["follower_id"]; $e_arr = $sub != '' ? unserialize($sub) : array(); if (sizeof($e_arr) > 0) { foreach ($e_arr as $ak => $av) { if ($is_sub == 0 and $av["sub_id"] == $session_id) { $is_sub = 1; break; } } } */ $sql = sprintf("SELECT `db_id` FROM `db_followers` WHERE `usr_id`='%s' AND `sub_id`='%s' LIMIT 1;", self::$user_id, $session_id); $rs = self::$db_cache ? self::$db->CacheExecute(self::$cfg['cache_view_sub_id'], $sql) : self::$db->execute($sql); $is_sub = $rs->fields["db_id"] ? 1 : 0; $user_isfollow = $is_sub; $user_followtotal = self::$usr_followcount; } $follow_txt = ($vuid == $session_id or $session_id == 0) ? self::$language["frontend.global.follow"] : ($user_isfollow == 1 ? self::$language["frontend.global.unfollow"] : self::$language["frontend.global.follow"]); $follow_cls = $session_id > 0 ? ($user_isfollow ? 'unfollow-action' : 'follow-action') : 'follow-action'; // $follow_cls .= intval($_SESSION["USER_ID"]) == 0 ? ' showSingle-lb-login" target="follow' : null; /* user subscription status */ if ($cfg["user_subscriptions"] == 1) { $is_sub = 0; /* $sql = sprintf("SELECT A.`subscriber_id`, B.`usr_subcount` FROM `db_subscribers` A, `db_accountuser` B WHERE A.`usr_id`=B.`usr_id` AND A.`usr_id`='%s' LIMIT 1;", self::$user_id); $rs = self::$db_cache ? self::$db->CacheExecute(self::$cfg['cache_view_sub_id'], $sql) : self::$db->execute($sql); $sub = $rs->fields["subscriber_id"]; $e_arr = $sub != '' ? unserialize($sub) : array(); if (sizeof($e_arr) > 0) { foreach ($e_arr as $ak => $av) { if ($is_sub == 0 and $av["sub_id"] == $session_id) { $is_sub = 1; break; } } } */ $sql = sprintf("SELECT `db_id` FROM `db_subscribers` WHERE `usr_id`='%s' AND `sub_id`='%s' LIMIT 1;", self::$user_id, $session_id); $rs = self::$db_cache ? self::$db->CacheExecute(self::$cfg['cache_view_sub_id'], $sql) : self::$db->execute($sql); $is_sub = $rs->fields["db_id"] ? 1 : 0; // $user_issub = $is_sub; if ($is_sub == 0) { $ts = self::$db->execute(sprintf("SELECT `db_id` FROM `db_subtemps` WHERE `usr_id`='%s' AND `usr_id_to`='%s' AND `pk_id`>'0' AND `expire_time`>='%s' AND `active`='1' LIMIT 1;", $session_id, (int) self::$user_id, date("Y-m-d H:i:s"))); if ($ts->fields["db_id"]) { $is_sub = 1; } } $user_issub = $is_sub; $user_subtotal = self::$usr_subcount; } $sub_txt = ($vuid == $session_id or $session_id == 0) ? self::$language["frontend.global.subscribe"] : ($is_sub == 1 ? self::$language["frontend.global.unsubscribe"] : self::$language["frontend.global.subscribe"]); // $sub_cls = ($vuid == intval($_SESSION["USER_ID"]) or intval($_SESSION["USER_ID"]) == 0) ? 'no-sub' : ($is_sub == 1 ? 'unsubscribe-button' : 'subscribe-button'); $sub_cls = $session_id > 0 ? ($is_sub ? 'unsubscribe-button' : 'subscribe-button') : 'follow-action'; // $sub_cls .= intval($_SESSION["USER_ID"]) == 0 ? ' showSingle-lb-login" target="subscribe' : null; /* channel links */ $ch_links_html = null; if (!empty($ch_links)) { $ch_links_html .= ''; } $header_image = file_exists($cfg["profile_images_dir"] . '/' . self::$user_key . '/' . self::$user_key . '-' . $ch_photos['default'] . '-large.jpg') ? $cfg["profile_images_url"] . '/' . self::$user_key . '/' . self::$user_key . '-' . $ch_photos['default'] . '-large.jpg' : false; $_uimg = VUseraccount::getProfileImage(self::$user_id); if ($is_sub) { $ub = 1; $suid = self::$dbc->singleFieldValue('db_accountuser', 'usr_id', 'usr_key', self::$user_key, (self::$db_cache ? self::$cfg['cache_view_sub_id'] : false)); $sql = sprintf("SELECT A.`db_id`, A.`expire_time`, B.`pk_name` FROM `db_subusers` A, `db_subtypes` B WHERE A.`usr_id`='%s' AND A.`usr_id_to`='%s' AND A.`pk_id`=B.`pk_id` AND A.`pk_id`>'0' LIMIT 1;", (int) $_SESSION["USER_ID"], $suid); $nn = self::$db_cache ? self::$db->CacheExecute(self::$cfg['cache_view_sub_id'], $sql) : self::$db->execute($sql); $sn = '' . $nn->fields["pk_name"] . '
' . $nn->fields["expire_time"] . ''; if (!$nn->fields["db_id"]) { $ub = 0; $sql = sprintf("SELECT A.`db_id`, A.`expire_time`, B.`pk_name` FROM `db_subtemps` A, `db_subtypes` B WHERE A.`usr_id`='%s' AND A.`usr_id_to`='%s' AND A.`pk_id`=B.`pk_id` AND A.`pk_id`>'0' AND A.`expire_time`>='%s' LIMIT 1;", (int) $_SESSION["USER_ID"], $suid, date("Y-m-d H:i:s")); $nn = self::$db_cache ? self::$db->CacheExecute(self::$cfg['cache_view_sub_id'], $sql) : self::$db->execute($sql); $sn = $nn->fields["pk_name"] . '
' . $nn->fields["expire_time"] . ''; } } /* start layout */ $html = $cfg['channel_backgrounds'] == 1 ? ' ' : null; $html .= '
' . ($cfg['channel_backgrounds'] == 1 ? '
' . ($header_image ? '' : null) . '

' . VAffiliate::affiliateBadge(((self::$usr_affiliate == 1 or self::$usr_partner == 1) ? 1 : 0), self::$affiliate_badge) . self::$channel_name . '

@' . self::$user_name . ' ' . self::$usr_followcount . ' ' . (self::$usr_followcount == 1 ? $language["frontend.global.follower"] : $language["frontend.global.followers"]) . ' ' . self::$usr_v_count . ' ' . (self::$usr_v_count == 1 ? $language["frontend.global.v"] : $language["frontend.global.v.p"]) . '
' . (self::$ch_cfg["ch_descr"] != '' ? ' ' : null) . ' ' . ($ch_links_html != '' ? ' ' : null) . '
' . (($_SESSION["USER_ID"] != self::$user_id and (self::$cfg["user_subscriptions"] == 1 or self::$cfg["user_follows"] == 1)) ? '
' : null) . '
' : null) . ' ' . (isset($_GET["fsn"]) ? VGenerate::noticeTpl('', '', self::$language["notif.success.subscribe"]) : null) . '
' . self::sectionModuleLoader() . '
'; $html .= (!isset($_SESSION["USER_ID"]) ? '

' . self::$language["frontend.global.follow"] . '

' . $visitor_html . '
' : null); $html .= VGenerate::declareJS('var ch_url = "' . VHref::channelURL(["username" => self::$user_name]) . '"; var ch_id = "' . self::$user_key . '";'); /* subscribe/unsubscribe action */ $html .= '
'; $ht_js = null; // $ht_js .= 'if(typeof $(".channel-image").html()=="undefined"){$(".tpl_channel .crop-height").css("height","auto")}else{$(".tpl_channel .crop-height").show()}'; if ($cfg["user_subscriptions"] == 1) { $ht_js .= 'c_url="' . $cfg["main_url"] . '/' . VHref::getKey('watch') . '";'; $ht_js .= 'rel=$(this).attr("rel-usr");if(rel==="' . $_SESSION["USER_KEY"] . '")return;'; $ht_js .= '$(document).on("click", ".unsubscribe-action", function(e){'; $ht_js .= 'if($("#sub-wrap .sub-txt:first span").text()=="' . self::$language["frontend.global.unsubscribed"] . '")return;'; $ht_js .= '$("#sub-wrap .sub-txt:first span").text("' . self::$language["frontend.global.loading"] . '");'; $ht_js .= '$.post("?do=user-unsubscribe", $("#user-files-form-"+rel).serialize(), function(data){'; $ht_js .= '$("#sub-wrap .sub-txt:first span").text("' . self::$language["frontend.global.unsubscribed"] . '");'; $ht_js .= '});'; $ht_js .= '});'; } // if ($cfg["user_follows"] == 1) { // $ht_js .= '$(document).on("click", ".follow-action", function(e){'; // $ht_js .= '$(".follow-txt").text("' . self::$language["frontend.global.loading"] . '");'; // $ht_js .= '$.post(c_url+"?do=user-follow", $("#user-files-form").serialize(), function(data){'; // $ht_js .= '$(".follow-txt").text("' . self::$language["frontend.global.followed"] . '");'; // $ht_js .= '});'; // $ht_js .= '});'; // $ht_js .= '$(document).on("click", ".unfollow-action", function(e){'; // $ht_js .= '$(".follow-txt").text("' . self::$language["frontend.global.loading"] . '");'; // $ht_js .= '$.post(c_url+"?do=user-unfollow", $("#user-files-form").serialize(), function(data){'; // $ht_js .= '$(".follow-txt").text("' . self::$language["frontend.global.unfollowed"] . '");'; // $ht_js .= '});'; // $ht_js .= '});'; // } /* follow/unfollow action */ if (self::$cfg["user_follows"] == 1) { $ht_js .= 'c_url="' . self::$cfg["main_url"] . '/' . VHref::getKey('watch') . '?a";'; $ht_js .= '$(document).on("click",".follow-action", function(e){'; if (isset($_SESSION["USER_ID"])) { $ht_js .= 'rel=$(this).attr("rel-usr");if(rel==="' . $_SESSION["USER_KEY"] . '")return;'; $ht_js .= '$(".follow-txt-"+rel+" span").text("' . self::$language["frontend.global.loading"] . '");'; $ht_js .= '$.post(c_url+"&do=user-follow", $("#user-files-form-"+rel).serialize(), function(data){'; $ht_js .= '$(".follow-txt-"+rel+" span").text("' . self::$language["frontend.global.followed"] . '");'; // $ht_js .= 'c=$(".content-current").attr("id").split("-");'; // $ht_js .= 'if($("#main-view-mode-2-"+c[1]).hasClass("active")) {$("#main-view-mode-2-"+c[1]+"-list .ch-"+rel+" .follow-txt").text("' . self::$language["frontend.global.followed"] . '");}'; $ht_js .= '});'; } else { $ht_js .= 'rel=$(this).attr("rel-name");$.fancybox.open({href:"#div-login",type:"inline",afterLoad:function(){$(".follow-username").text(rel);$(".tooltip").hide()},opts:{onComplete:function(){}},margin:0,minWidth:"50%",maxWidth:"95%",maxHeight:"90%"});'; } $ht_js .= '});'; if (isset($_SESSION["USER_ID"])) { $ht_js .= '$(document).on("click",".unfollow-action", function(e){'; $ht_js .= 'rel=$(this).attr("rel-usr");if(rel=== "' . $_SESSION["USER_KEY"] . '")return;'; $ht_js .= '$(".follow-txt-"+rel+" span").text("' . self::$language["frontend.global.loading"] . '");'; $ht_js .= '$.post(c_url+"&do=user-unfollow", $("#user-files-form-"+rel).serialize(), function(data){'; $ht_js .= '$(".follow-txt-"+rel+" span").text("' . self::$language["frontend.global.unfollowed"] . '");'; // $ht_js .= 'c=$(".content-current").attr("id").split("-");'; // $ht_js .= 'if($("#main-view-mode-2-"+c[1]).hasClass("active")) {$("#main-view-mode-2-"+c[1]+"-list .ch-"+rel+" .follow-txt").text("' . self::$language["frontend.global.unfollowed"] . '");}'; $ht_js .= '});'; $ht_js .= '});'; } } $html .= ''; return $html; } /* update channel views number */ public static function updateViews() { $upage_id = self::$user_id; if ($upage_id > 0) { $view = new VView; VView::updateViewLogs('channel', $upage_id); } } /* generate content for each section module */ private static function sectionModuleLoader() { global $class_smarty, $class_filter; switch (self::$module) { case "": case self::$href["activity"]: $display_page = self::activityTimeline(); break; case self::$href["broadcasts"]: case self::$href["videos"]: case self::$href["shorts"]: case self::$href["images"]: case self::$href["audios"]: case self::$href["documents"]: case self::$href["blogs"]: if (isset($_GET["query"])) { $_SESSION["q"] = $class_filter->clr_str(htmlspecialchars_decode($_GET["query"])); } else { unset($_SESSION["q"]); } $browse = new VBrowse; $files = new VFiles; $display_page = VBrowse::browseLayout(self::$module); break; case self::$href["playlists"]: $playlist = new VPlaylist; $files = new VFiles; $display_page = VFiles::listPlaylists(); break; case self::$href["comments"]: case self::$href["discussion"]: $view = new VView; $browse = new VBrowse; $ch = new VChannel; $comm = new VChannelComments; $vcomm = null; $type = 'channel'; $session_id = (int) $_SESSION["USER_ID"]; $cfg["file_comment_spam"] = 1; // $ht_js = 'var comm_sec = "' . VHref::getKey("see_comments") . '"; var comm_url = "' . self::$cfg["main_url"] . '/"+comm_sec+"?' . $type[0] . '=' . self::$user_id . '"; var m_loading = "";'; $ht_js .= 'var comm_sec = "' . VHref::getKey("see_comments") . '";'; $ht_js .= 'var comm_url = "' . $cfg["main_url"] . '/"+comm_sec+"?' . self::$type[0] . '=' . self::$user_id . '"; var m_loading = "";'; /* inview plugin */ $ht_js .= '!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){function i(){var b,c,d={height:f.innerHeight,width:f.innerWidth};return d.height||(b=e.compatMode,(b||!a.support.boxModel)&&(c="CSS1Compat"===b?g:e.body,d={height:c.clientHeight,width:c.clientWidth})),d}function j(){return{top:f.pageYOffset||g.scrollTop||e.body.scrollTop,left:f.pageXOffset||g.scrollLeft||e.body.scrollLeft}}function k(){if(b.length){var e=0,f=a.map(b,function(a){var b=a.data.selector,c=a.$element;return b?c.find(b):c});for(c=c||i(),d=d||j();ed.top&&l.topd.left&&l.left '.self::$language["view.files.comm.loading"].'\');setTimeout(function () {$.post(comm_url+"&do=comm-load", {comm_type: "'.$type.'", comm_uid: "'.self::$user_id.'"}, function(data){t.replaceWith(\'
\'+data+\'
\');t.html(data);$("#comment-loader-before").detach();});},100);}}if (!$("#comment-loader").hasClass("loaded")){commentLazyLoad();}'; // $ht_js .= '$(function(){$(document).on({click: function (e) {var f1 = $(this).attr("id").substr(3); if($("#r-"+f1).val() != ""){$("#' . $type . '-comment"+f1).mask(m_loading);$.post(comm_url+"&do=comm-reply", $("#comm-reply-form"+f1).serialize(), function(data){$("#comment-load").html(data);$("#r-"+f1).val("");$("#' . $type . '-comment"+f1).unmask();$("#comm-post-response").insertBefore("#"+f1);});}}},".reply-comment-button");});'; /* comment loading, submit replies */ $ht_js .= (self::$cfg["channel_comments"] == 1 and $vcomm != 'none') ? ' function commentLazyLoad(){ if(!$("#comment-load").hasClass("loaded")){ $(document).on("inview","#wrapper #div-comments",function(event,isInView,visiblePartX,visiblePartY){ if(isInView && !$("#comment-load").hasClass("loaded")){ var t = $("#comment-loader");t.html(\'
' . self::$language["view.files.comm.loading"] . '
\'); setTimeout(function(){ $.post(comm_url+"&do=comm-load",{comm_type:"' . self::$type . '",comm_uid:"' . $vuid . '"},function(data){ t.replaceWith(\'
\'+data+\'
\'); $("#comment-loader-before").detach(); $(".comm-body").each(function(){h=$(this).height();$(this).parent().find("[id^=comm-actions2-over] span").css("top",-h);$(this).parent().find("[id^=comment-actions-dd] .accordion.cacc").css("top",-h); }); $(".c-pinned").each(function(){ t = $(this); if (t.parent().parent().find(".comm-replies-show").length==0) { t.parent().parent().parent().find(".response_holder").detach(); } }); }); },5); } });} }if(!$("#comment-load").hasClass("loaded")){commentLazyLoad();}' : null; /* pagination */ $ht_js .= 'var p=(parseInt($("#cnr").text())||1);var pag="&page=" + p;'; $ht_js .= '$(document).on({click:function(e){'; $ht_js .= 'var p=parseInt($("#cnr").text());'; $ht_js .= 'var comm_link = comm_url + "&do=comm-load&page=" + parseInt(p+1);'; $ht_js .= '$("#comm-spinner").show().mask(m_loading);'; $ht_js .= '$.post(comm_link, $("#comm-post-form").serialize(), function(data){'; $ht_js .= '$(data).insertBefore(".comm-pag"); $("#cnr").text( parseInt(p+1) );'; $ht_js .= '$(".comm-toggle-replies").each(function(){var t = $(this); var _id = t.attr("id").substr(3); if (typeof($("#"+_id+" .response_holder").html()) == "undefined"){t.detach();}});'; $ht_js .= '$(".comments_activity").each(function(){var t = $(this); var _id = t.attr("id"); if (!t.hasClass("response") && typeof($("#"+_id+" > .response_holder").html()) !== "undefined") {$("#"+_id+" > .response_holder").hide();} });'; $ht_js .= '$(".comm-body").each(function(){h=$(this).height();$(this).parent().find("[id^=comm-actions2-over] span").css("top",-h);$(this).parent().find("[id^=comment-actions-dd] .accordion.cacc").css("top",-h);});'; $ht_js .= '$("#comm-spinner").unmask();'; $ht_js .= '});}}, ".comm-page-next");'; /* page in view */ $ht_js .= '$(document).on("inview",".comm-pag",function(event,isInView,visiblePartX,visiblePartY){'; $ht_js .= 'if(isInView){$(".comm-page-next").click();}'; $ht_js .= '});'; // $ht_js .= '$(document).on({inview:function(e){alert(2)}}, "header");'; if (self::$cfg["channel_comments"] == 1 and $vcomm != 'none' and $session_id > 0) { /* comment like */ $ht_js .= '$(document).on({click: function(e){'; $ht_js .= 'var f1 = $(this).parent().next().html(); var f2 = $("#comm-post-form").serialize(); var frm = "c_key="+f1+"&"+f2;'; $ht_js .= 'var t = $(this); t.find("i").removeClass("icon-thumbs-up").addClass("spinner icon-spinner");'; $ht_js .= '$.post(comm_url+"&do=comm-like", frm, function(data){'; $ht_js .= 't.closest(".ucls-links").append(data);'; // $(".comm-input-action").val("");'; $ht_js .= 't.find("i").addClass("icon-thumbs-up").removeClass("spinner icon-spinner");'; $ht_js .= '});'; $ht_js .= '}}, ".comm-like-action");'; //done $ht_js .= '$(document).on({click: function(e){'; $ht_js .= 'var f1 = $(this).parent().next().html(); var f2 = $("#comm-post-form").serialize(); var frm = "c_key="+f1+"&"+f2;'; $ht_js .= 'var t = $(this); t.find("i").removeClass("icon-thumbs-up2").addClass("spinner icon-spinner");'; $ht_js .= '$.post(comm_url+"&do=comm-dislike", frm, function(data){'; $ht_js .= 't.closest(".ucls-links").append(data);'; // $(".comm-input-action").val("");'; $ht_js .= 't.find("i").addClass("icon-thumbs-up2").removeClass("spinner icon-spinner");'; $ht_js .= '});'; $ht_js .= '}}, ".comm-dislike-action");'; //done /* approve */ $ht_js .= '$(document).on({click: function(e){'; $ht_js .= 'var f1 = $(this).parent().parent().next().text(); var f2 = $("#comm-post-form").serialize(); var frm = "c_key="+f1+"&"+f2;'; $ht_js .= 'var t = $(this); t.find("i").addClass("spinner icon-spinner");'; $ht_js .= '$.post(comm_url+"&do=comm-approve", frm, function(data){'; $ht_js .= 't.closest(".ucls-links").append(data);'; // $(".comm-input-action").val("");'; $ht_js .= 't.parent().addClass("no-display"); t.parent().next().removeClass("no-display");'; $ht_js .= 't.find("i").removeClass("spinner icon-spinner");'; $ht_js .= '});'; $ht_js .= '}},".comm-approve");'; //done /* suspend */ $ht_js .= '$(document).on({click: function(e){'; $ht_js .= 'var f1 = $(this).parent().parent().next().text(); var f2 = $("#comm-post-form").serialize(); var frm = "c_key="+f1+"&"+f2;'; $ht_js .= 'var t = $(this); t.find("i").removeClass("icon-lock").addClass("spinner icon-spinner");'; $ht_js .= '$.post(comm_url+"&do=comm-suspend", frm, function(data){'; $ht_js .= 't.closest(".ucls-links").append(data);'; // $(".comm-input-action").val("");'; $ht_js .= 't.find("i").removeClass("spinner icon-spinner");'; $ht_js .= 't.parent().addClass("no-display"); t.parent().prev().removeClass("no-display");'; $ht_js .= '});'; $ht_js .= '}},".comm-suspend");'; //done /* block user */ $ht_js .= '$(document).on({click: function(e){'; $ht_js .= 'var f1 = $(this).parent().parent().next().text(); var f2 = $("#comm-post-form").serialize(); var frm = "c_key="+f1+"&"+f2;'; $ht_js .= 'var t = $(this); t.find("i").removeClass("icon-blocked").addClass("spinner icon-spinner");$("#"+f1).mask("");'; $ht_js .= '$.post(comm_url+"&do=comm-block", frm, function(data){'; $ht_js .= '$("#comment-load").html(data);'; // $(".comm-input-action").val("");'; $ht_js .= 't.find("i").removeClass("spinner icon-spinner").addClass("icon-blocked");$("#"+f1).unmask();'; $ht_js .= 't.parent().addClass("no-display"); t.parent().prev().removeClass("no-display");'; $ht_js .= '});'; $ht_js .= '}},".comm-block");'; //done /* spam */ if ($cfg["file_comment_spam"] == 1) { $ht_js .= '$(document).on({click: function(e){'; $ht_js .= 'var f1 = $(this).parent().parent().next().text(); var f2 = $("#comm-post-form").serialize(); var frm = "c_key="+f1+"&"+f2;'; $ht_js .= 'var t = $(this); t.find("i").removeClass("icon-lock").addClass("spinner icon-spinner");'; $ht_js .= '$.post(comm_url+"&do=comm-spam", frm, function(data){'; $ht_js .= '$("#comment-load").html(data);'; // $(".comm-input-action").val("");'; $ht_js .= 't.find("i").addClass("icon-lock").removeClass("spinner icon-spinner");'; $ht_js .= '});'; $ht_js .= '}},".comm-spam");'; //done } /* delete */ $ht_js .= '$(document).on({click: function(e){var message = "' . $language["view.files.comm.confirm"] . '";var answer = confirm(message);if(answer){'; $ht_js .= 'var f1 = $(this).parent().parent().next().text(); var f2 = $("#comm-post-form").serialize(); var frm = "c_key="+f1+"&"+f2;'; $ht_js .= 'var t = $(this); t.find("i").removeClass("icon-times").addClass("spinner icon-spinner");'; $ht_js .= '$.post(comm_url+"&do=comm-delete", frm, function(data){'; $ht_js .= 't.closest(".ucls-links").append(data);'; // $(".comm-input-action").val("");'; $ht_js .= 't.find("i").addClass("icon-times").removeClass("spinner icon-spinner");'; $ht_js .= '});}return false;'; $ht_js .= '}},".comm-delete");'; //done /* click to post comment edit */ $ht_js .= '$(document).on({click:function(e){'; $ht_js .= 'var f1=$(this).attr("id").substr(3);'; $ht_js .= 'if($("#e-"+f1).val()!=""){'; $ht_js .= 'comm_url="' . self::$cfg["main_url"] . '/' . VHref::getKey("see_comments") . '?' . self::$type[0] . '=' . self::$user_id . '";'; $ht_js .= '$("#' . self::$type . '-comment"+f1).mask(" ");'; $ht_js .= '$.post(comm_url+"&do=comm-edit",$("#comm-edit-form"+f1).serialize(),function(data){'; $ht_js .= '$("#e-"+f1).append(data);'; $ht_js .= '$("#' . self::$type . '-comment"+f1).unmask();'; $ht_js .= 'return false;});'; $ht_js .= '}}},".edit-comment-button");'; /* click to post comment reply */ $ht_js .= '$(document).on({click:function(e){'; $ht_js .= 'var f1=$(this).attr("id").substr(3);'; $ht_js .= 'if($("#r-"+f1).val()!=""){'; $ht_js .= 'comm_url="' . self::$cfg["main_url"] . '/' . VHref::getKey("see_comments") . '?' . self::$type[0] . '=' . self::$user_id . '";'; $ht_js .= '$("#' . self::$type . '-comment"+f1).mask(" ");'; $ht_js .= '$.post(comm_url+"&do=comm-reply",$("#comm-reply-form"+f1).serialize(),function(data){'; $ht_js .= '$("#comment-load").html(data);$("#r-"+f1).val("");'; $ht_js .= '$("#' . self::$type . '-comment"+f1).unmask();'; $ht_js .= '$("#comm-post-response").insertBefore("#"+f1);'; $ht_js .= '$(".response_holder .c-pinned").each(function(){c=$(this).parent().parent().parent().clone(true);c.insertAfter($(".comments_activity:first")).removeClass("response");});'; ////////////////////// $ht_js .= 'return false;});'; $ht_js .= '}}},".reply-comment-button");'; /* click to pin comment */ $ht_js .= '$(document).on({click: function(e){'; $ht_js .= 'var f1 = $(this).parent().parent().next().text(); var f2 = $("#comm-post-form").serialize(); var frm = "c_key="+f1+"&"+f2;'; $ht_js .= 'var t = $(this); t.find("i").removeClass("icon-pushpin").addClass("spinner icon-spinner");$("#"+f1).mask("");'; $ht_js .= '$.post(comm_url+"&do=comm-pin", frm, function(data){'; $ht_js .= '$("#comment-load").html(data);'; // $(".comm-input-action").val("");'; $ht_js .= 't.find("i").removeClass("spinner icon-spinner").addClass("icon-pushpin");$("#"+f1).unmask();'; $ht_js .= 't.parent().addClass("no-display"); t.parent().prev().removeClass("no-display");'; $ht_js .= '});'; $ht_js .= '}},".comm-pin");'; //done /* click to unpin comment */ $ht_js .= '$(document).on({click: function(e){'; $ht_js .= 'var f1 = $(this).parent().parent().next().text(); var f2 = $("#comm-post-form").serialize(); var frm = "c_key="+f1+"&"+f2;'; $ht_js .= 'var t = $(this); t.find("i").removeClass("icon-pushpin").addClass("spinner icon-spinner");$("#"+f1).mask("");'; $ht_js .= '$.post(comm_url+"&do=comm-unpin", frm, function(data){'; $ht_js .= '$("#comment-load").html(data);'; // $(".comm-input-action").val("");'; $ht_js .= 't.find("i").removeClass("spinner icon-spinner").addClass("icon-pushpin");$("#"+f1).unmask();'; $ht_js .= 't.parent().addClass("no-display"); t.parent().prev().removeClass("no-display");'; $ht_js .= '});'; $ht_js .= '}},".comm-unpin");'; //done /* click on main comment emotes trigger */ $ht_js .= '$(document).on({click: function(e){'; $ht_js .= 'if(!$("#ntm em-emoji-picker").is(":visible")){'; $ht_js .= '$(this).removeClass("icon-smiley").addClass("icon-smiley2");$("#ntm em-emoji-picker").css("display", "flex");'; $ht_js .= '}else{'; $ht_js .= '$(this).addClass("icon-smiley").removeClass("icon-smiley2");$("#ntm em-emoji-picker").css("display", "none");'; $ht_js .= '}'; $ht_js .= '}},"#comment-emotes i");'; //done /* click on reply comment emotes trigger */ $ht_js .= '$(document).on({click: function(e){'; $ht_js .= 'if(!$(this).next().is(":visible")){'; $ht_js .= '$(this).removeClass("icon-smiley").addClass("icon-smiley2");$(this).next().css("display", "flex");'; $ht_js .= '}else{'; $ht_js .= '$(this).addClass("icon-smiley").removeClass("icon-smiley2");$(this).next().css("display", "none");'; $ht_js .= '}'; $ht_js .= '}},".comment-emotes i");'; //done } /* COMMENTS */ $html .= '
'; $html .= VGenerate::simpleDivWrap('', 'comment-loader-before', ''); $html .= (self::$cfg["channel_comments"] == 1 and $vcomm != 'none') ? VGenerate::simpleDivWrap('', 'comment-loader', '') : VGenerate::simpleDivWrap('is-disabled', '', '' . self::$language["view.files.comm.disabled"] . ''); $html .= '
'; // $html = VGenerate::simpleDivWrap('', 'comment-loader-before', ''); // $html .= VGenerate::simpleDivWrap('', 'comment-loader', ''); $html .= VGenerate::declareJS($ht_js); $display_page = $html; break; case self::$href["about"]: $display_page = self::aboutPage(); break; case self::$href["subscribers"]: $display_page = self::userList(self::$href["subscribers"]); break; case self::$href["subscriptions"]: $display_page = self::userList(self::$href["subscriptions"]); break; case self::$href["followers"]: $display_page = self::userList(self::$href["followers"]); break; case self::$href["following"]: $display_page = self::userList(self::$href["following"]); break; case self::$href["channels"]: $display_page = self::userList(self::$href["channels"]); break; } $html = '
' . $display_page . '
'; return $html; } /* channel page - subscribers, subscriptions */ private static function userList($type) { $db = self::$db; $class_database = self::$dbc; $cfg = self::$cfg; $language = self::$language; $class_filter = self::$filter; switch ($type) { case self::$href["channels"]: $h3s = self::$ch_channels["uc_title"]; $ch = self::$ch_channels["uc_names"]; $ic = 'icon-users'; if (!empty($ch)) { $ids = array(); $is_sub_array = array(); foreach ($ch as $u) { $uu = $class_database->singleFieldValue('db_accountuser', 'usr_id', 'usr_user', $class_filter->clr_str($u)); if ($uu) { $ids[] = $uu; } } if (!empty($ids)) { foreach ($ids as $id) { $rs = $db->execute(sprintf("SELECT `db_id` FROM `db_followers` WHERE `usr_id`='%s' AND `sub_id`='%s' LIMIT 1;", $id, self::getUserID())); if ($rs->fields["db_id"]) { $is_sub_array[] = $id; } /* $rs = $db->execute(sprintf("SELECT `subscriber_id` FROM `db_subscribers` WHERE `usr_id`='%s' LIMIT 1;", $id)); if ($rs->fields["subscriber_id"]) { $s = unserialize($rs->fields["subscriber_id"]); if (!empty($s)) { foreach ($s as $ar) { if ($ar["sub_id"] == self::getUserID()) { $is_sub_array[] = $id; } } } } */ } } } break; case self::$href["subscribers"]: case self::$href["followers"]: $ids = array(); break; case self::$href["subscriptions"]: case self::$href["following"]: // return; $ic = 'icon-users5'; $h3s = $type == self::$href["subscriptions"] ? $language["subnav.entry.sub"] : $language["frontend.global.following.cap"]; $s = 0; $sub_ar = array(); // $e_arr = array(); $ids = array(); $is_sub_array = array(); /* if ($type == self::$href["subscriptions"]) { $sub = $db->execute(sprintf("SELECT `usr_id`, `subscriber_id` FROM `db_subscribers` WHERE `db_active`='1' AND `usr_id`!='%s' AND `subscriber_id`!='';", self::$user_id)); } else { $sub = $db->execute(sprintf("SELECT `usr_id`, `follower_id` FROM `db_followers` WHERE `db_active`='1' AND `usr_id`!='%s' AND `follower_id`!='';", self::$user_id)); } */ if ($type == self::$href["subscriptions"]) { $sub = $db->execute(sprintf("SELECT `db_id`, `usr_id` FROM `db_subscribers` WHERE `sub_id`='%s';", self::$user_id)); } else { $sub = $db->execute(sprintf("SELECT `db_id`, `usr_id` FROM `db_followers` WHERE `sub_id`='%s';", self::$user_id)); } // $subs = $sub->getrows(); if ($sub->fields["db_id"]) { while (!$sub->EOF) { $ids[] = $sub->fields["usr_id"]; $is_sub_array[] = $sub->fields["usr_id"]; $sub->MoveNext(); } } /* for ($i = 0; $i < count($subs); $i++) { $sub_ar[$i] = $type == self::$href["subscriptions"] ? unserialize($subs[$i]["subscriber_id"]) : unserialize($subs[$i]["follower_id"]); } */ /* foreach ($sub_ar as $val) { foreach ($val as $vl) { if ($vl["sub_id"] == self::$user_id) { // $e_arr[$s]["sub_id"] = $subs[$s]["usr_id"]; $ids[] = $subs[$s]["usr_id"]; $is_sub_array[] = $subs[$s]["usr_id"]; } } $s = $s + 1; } */ break; } if (empty($ids)) { return; } $html_li = null; $sql = sprintf("SELECT A.`usr_id`, A.`usr_key`, A.`usr_user`, A.`usr_partner`, A.`usr_affiliate`, A.`affiliate_badge`, A.`usr_dname`, A.`ch_views`, A.`ch_title`, A.`usr_photo`, A.`usr_profileinc`, A.`usr_subcount`, A.`usr_followcount` FROM `db_accountuser` A WHERE A.`usr_status`='1' AND A.`usr_id` IN (%s);", implode(',', $ids)); $res = $db->execute($sql); if ($res->fields["usr_id"]) { $count = 1; while (!$res->EOF) { $uid = $res->fields["usr_id"]; $usr_key = $res->fields["usr_key"]; $usr_photo = $res->fields["usr_photo"]; $usr_inc = $res->fields["usr_profileinc"]; $bg_url = VUseraccount::getProfileImage_inc($usr_key, $usr_photo, $usr_inc); $h3 = ($res->fields["usr_dname"] != '' ? $res->fields["usr_dname"] : ($res->fields["ch_title"] != '' ? $res->fields["ch_title"] : $res->fields["usr_user"])); $is_sub = in_array($res->fields["usr_id"], $is_sub_array) ? true : false; $a_cls = (int) $_SESSION["USER_ID"] > 0 ? ($is_sub ? 'unfollow-action' : 'follow-action') : 'follow-action'; $a_txt = $is_sub ? $language["frontend.global.unfollow"] : (($uid == (int) $_SESSION["USER_ID"]) ? $language["frontend.global.followers"] : $language["frontend.global.follow"]); // $a_txt = $is_sub ? 'unsubscribe' : 'subscribe'; $col_cls = 'fifths'; $html_li .= ''; /* $html_li .= '
  • ' . VAffiliate::affiliateBadge((($res->fields["usr_affiliate"] == 1 or $res->fields["usr_partner"] == 1) ? 1 : 0), $res->fields["affiliate_badge"]) . $h3 . '

    ' . $res->fields["ch_views"] . ' ' . ($res->fields["ch_views"] == 1 ? $language["frontend.global.view"] : $language["frontend.global.views"]) . '

    fields["usr_user"] . '">' . $language["main.text.view.channel"] . '

  • '; */ $res->MoveNext(); $count += 1; } } $html = '

    ' . $h3s . '

      ' . $html_li . '
    '; $html .= ''; return $html; } /* channel page - about section */ private static function aboutPage() { $cfg = self::$cfg; $db = self::$db; $class_database = self::$dbc; $language = self::$language; $ch_cfg = self::$ch_cfg; $ch_links = self::$ch_links; $sub_count = self::subCount(); if (!empty($ch_links)) { $ch_links_html = '
      '; foreach ($ch_links as $k => $url) { $c = ($k % 2 == 0) ? 'vs-column half' : 'vs-column half fit'; $ch_links_html .= '
    • ' . $url["title"] . '
    • '; } $ch_links_html .= '
    '; } if (self::getUserID() > 0) { $upage_id = self::getUserID(); $upage_user = self::$user_name; $fr_chk = $db->execute(sprintf("SELECT `ct_friend` from `db_usercontacts` WHERE `usr_id`='%s' AND `ct_username`='%s' LIMIT 1;", $upage_id, $upage_user)); $is_fr = $fr_chk->fields["ct_friend"]; $is_fr = $is_fr == 1 ? 1 : 0; $is_sub = 0; $is_bl = VContacts::getBlockStatus($upage_id, $upage_user); $is_bl_sub = VContacts::getBlockStatus(self::$user_id, $_SESSION["USER_NAME"]); $bl_sub = VContacts::getBlockCfg('bl_subscribe', $upage_id, $_SESSION["USER_NAME"]); $sub = $class_database->singleFieldValue('db_subscribers', 'subscriber_id', 'usr_id', $upage_id); $cls_friend = ' profile-friend-' . ($is_fr == 1 ? 'remove' : 'add'); $cls_block = ' profile-' . ($is_bl == 1 ? 'unblock' : 'block'); if ($sub != '') { $sub_ar = unserialize($sub); foreach ($sub_ar as $val) { if ($val["sub_id"] == $upage_id) { $is_sub = 1; break; } } } $ht = ''; } $profile_html = null; if ($ch_cfg["ch_profile_details"] == 1) { $profile_fields = array('usr_id', 'usr_name', 'usr_description', 'usr_website', 'usr_birthday', 'usr_showage', 'usr_gender', 'usr_relation', 'usr_phone', 'usr_fax', 'usr_town', 'usr_city', 'usr_zip', 'usr_country', 'usr_occupations', 'usr_companies', 'usr_schools', 'usr_interests', 'usr_movies', 'usr_music', 'usr_books'); $profile_labels = array(0, $language["upage.text.owner"], 'usr_description', 'usr_website', $language["account.profile.personal.bday"], 'usr_showage', $language["account.profile.personal.gender"], $language["account.profile.personal.rel"], $language["account.profile.about.phone"], $language["account.profile.about.fax"], $language["account.profile.location.town"], $language["account.profile.location.city"], $language["account.profile.location.zip"], $language["account.profile.location.country"], $language["account.profile.job.occup"], $language["account.profile.job.companies"], $language["account.profile.education"], $language["account.profile.interests"], $language["account.profile.interests.movies"], $language["account.profile.interests.music"], $language["account.profile.interests.books"]); $profile_icons = array(0, 'icon-user', '', '', 'iconBe-calendar2', 'iconBe-calendar2', 'icon-tag', 'icon-heart2', 'icon-rss', 'icon-rss', 'icon-globe', 'icon-globe', 'icon-globe', 'icon-globe', 'icon-gear', 'icon-gear', 'icon-group', 'icon-group', 'icon-camera2', 'icon-music', 'icon-books'); $sql = sprintf("SELECT %s FROM `db_accountuser` WHERE `usr_id`='%s' LIMIT 1;", str_replace('usr_name', 'CONCAT(usr_fname, " ", usr_lname) AS usr_name', implode(',', $profile_fields)), self::$user_id); $profile_info = self::$db_cache ? $db->execute($cfg["cache_channels_about"], $sql) : $db->execute($sql); if ($profile_info->fields['usr_id']) { unset($profile_fields[0]); foreach ($profile_fields as $i => $key) { $label = $profile_labels[$i]; $label = ($label == 'usr_description' or $label == 'usr_website') ? ' ' : $label; $value = $profile_info->fields[$key]; if ($label == 'usr_showage' and $value == 1) { $label = $language["account.profile.personal.age"]; $bdate = $profile_info->fields['usr_birthday']; $value = $bdate != '0000-00-00' ? VUserinfo::ageFromString($bdate) : '---'; } elseif ($label == 'usr_showage' and $value == 0) { $value = null; } elseif ($label == $language["account.profile.personal.bday"] and $value != '0000-00-00') { $value = date('M N, o', strtotime($value)); } $value = $key == 'usr_website' ? '' . $value . '' : $value; if ($value != '' and $value != '---' and $value != '0000-00-00') { $profile_html .= '
    '; $profile_html .= '
    ' . $label . '
    '; $profile_html .= '
    ' . $value . '
    '; $profile_html .= '
    '; $profile_html .= '
    '; } } } } // ' . $language["frontend.global.since"] . ' ' . strftime("%b %e, %G", strtotime($ch_cfg["ch_join"])) . ' // ' . $ch_cfg["ch_views"] . ' ' . ($ch_cfg["ch_views"] == 1 ? $language["frontend.global.view"] : $language["frontend.global.views"]) $profile_stats = '
    '; $profile_stats .= '
    ' . $language["frontend.global.since"] . '
    '; $profile_stats .= '
    ' . date('M j, o', strtotime($ch_cfg["ch_join"])) . '
    '; $profile_stats .= '
    '; $profile_stats .= '
    '; $profile_stats .= '
    '; $profile_stats .= '
    ' . $language["frontend.global.views.stat"] . '
    '; $profile_stats .= '
    ' . $ch_cfg["ch_views"] . '
    '; $profile_stats .= '
    '; $profile_stats .= '
    '; $profile_stats .= '
    '; $profile_stats .= '
    ' . $language["frontend.global.followers.cap"] . '
    '; $profile_stats .= '
    ' . self::$usr_followcount . '
    '; $profile_stats .= '
    '; $profile_stats .= '
    '; $profile_stats .= '
    '; $profile_stats .= '
    ' . $language["frontend.global.subscribers.cap"] . '
    '; $profile_stats .= '
    ' . self::$usr_subcount . '
    '; $profile_stats .= '
    '; $profile_stats .= '
    '; $links = null; $js = null; if (self::getUserID() > 0 and self::getUserID() != self::$user_id) { $text1 = ($is_fr == 1 ? $language["upage.text.profile.rem.friend"] : $language["upage.text.profile.add.friend"]); $text2 = ($is_bl == 1 ? $language["upage.text.profile.unblock.user"] : $language["upage.text.profile.block.user"]); $text3 = $language["upage.text.profile.send.message"]; $links .= '
    '; $links .= $cfg["user_friends"] == 1 ? '' : null; $links .= $cfg["user_blocking"] == 1 ? '' : null; $links .= $cfg["internal_messaging"] == 1 ? '' : null; $links .= VGenerate::simpleDivWrap('left-float no-display', '', ''); $links .= '
    '; $js .= '$(".profile-message").click(function(){' . (self::sessionMessageName($upage_user)) . ' var tlink = "' . $cfg["main_url"] . '/' . VHref::getKey("messages") . '?src=upage" + "&" + "mid=' . strtoupper(VUserinfo::generateRandomString()) . '"; window.location.href = html2amp(tlink); return false;});'; $js .= '$(".profile-friend-add").click(function(){ $("#section-about").mask(" "); $.post("?a=cb-addfr", $("#user-actions-form").serialize(), function(data) { $("#action-response").html(data); $("#section-about").unmask(); }); });'; $js .= '$(".profile-friend-remove").click(function(){ $("#section-about").mask(" "); $.post("?a=cb-remfr", $("#user-actions-form").serialize(), function(data) { $("#action-response").html(data); $("#section-about").unmask(); }); });'; $js .= '$(".profile-block").click(function(){ $("#section-about").mask(" "); $.post("?a=cb-block", $("#user-actions-form").serialize(), function(data) { $("#action-response").html(data); $("#section-about").unmask(); }); });'; $js .= '$(".profile-unblock").click(function(){ $("#section-about").mask(" "); $.post("?a=cb-unblock", $("#user-actions-form").serialize(), function(data) { $("#action-response").html(data); $("#section-about").unmask(); }); });'; } $d = preg_replace('@(https?://([-\w\.]+[-\w])+(:\d+)?(/([\w/_\.#-]*(\?\S+)?[^\.\s])?)?)@', '$1', $ch_cfg["ch_descr"]); $html = '

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

    ' . $d . '

    '; if ($ch_links_html != '') { $html .= '

    ' . $language["channel.text.links"] . '



    '; } if ($profile_html != '') { $html .= '

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

    ' . $profile_html . '
    '; } $html .= '

    ' . $language["upage.text.stats"] . '

    ' . $profile_stats . '

    ' . $links . '
    '; $html .= '
    '; $html .= $js != '' ? VGenerate::declareJS($js) : null; return $html; } /* store name to be set when message sending */ private static function sessionMessageName($from) { $_SESSION["channel_msg"] = $from; } /* user actions (add/remove friend, block/unblock */ public static function userActions($action) { //global $db, $class_database; $db = self::$db; $class_database = self::$dbc; $ct_user = self::$user_name; $ct_uid = self::getUserID(); $ct = $db->execute(sprintf("SELECT `ct_id` FROM `db_usercontacts` WHERE `usr_id`='%s' AND `ct_username`='%s' AND `ct_active`='1' LIMIT 1;", $ct_uid, $ct_user)); $ct_id = $ct->fields["ct_id"]; switch ($action) { case "cb-remfr": case "cb-block": case "cb-unblock": $update_id = $ct_id; break; case "cb-addfr": if ($ct_id > 0) { $update_id = $ct_id; } else { $block_db = serialize(array("bl_files" => 1, "bl_channel" => 1, "bl_comments" => 1, "bl_messages" => 1, "bl_subscribe" => 1)); $update_ar = array("usr_id" => $ct_uid, "pwd_id" => VUserinfo::generateRandomString(10), "ct_name" => "", "ct_username" => $ct_user, "ct_email" => "", "ct_datetime" => date("Y-m-d H:i:s"), "ct_block_cfg" => $block_db); $update_do = $class_database->doInsert('db_usercontacts', $update_ar); $update_id = $db->Insert_ID(); } break; } if ($update_id > 0) { $do_action = VContacts::ctAction($action, array($update_id), 1); } } /* get subscriber count */ private static function subCount() { return self::$usr_subcount; // $t = 0; // $db = self::$db; // $rs = $db->execute(sprintf("SELECT `subscriber_id` FROM `db_subscribers` WHERE `usr_id`='%s' LIMIT 1;", self::$user_id)); // if ($rs->fields["subscriber_id"]) { // $s = unserialize($rs->fields["subscriber_id"]); // $t = count($s); // } // return $t; } /* check module and set active tab */ private static function activeTabClass($check) { return ($check == self::$module ? 'tab-current swiper-slide-current' : (($check == 'activity' && self::$module == '') ? 'tab-current swiper-slide-current' : null)); } /* activity timeline */ private static function activityTimeline() { $cfg = self::$cfg; $db = self::$db; $ch_uid = self::$user_id; $language = self::$language; $class_database = self::$dbc; $allow_cfg = $ch_uid == self::getUserID() ? 1 : 0; $row = unserialize($class_database->singleFieldValue('db_accountuser', 'ch_rownum', 'usr_id', $ch_uid)); $ev = $db->execute(sprintf("SELECT * FROM `db_trackactivity` WHERE `usr_id`='%s' LIMIT 1;", $ch_uid)); $db_ar1 = $ev->getrows(); $bl_db = $cfg["channel_bulletins"] == 1 ? " OR `act_type` LIKE '%bulletin%' " : null; $bl_db .= ($cfg["video_module"] == 1 and $cfg["file_favorites"] == 1 and $db_ar1[0]["log_fav"] == 1) ? " OR `act_type` LIKE 'favorite:video%' " : null; $bl_db .= ($cfg["short_module"] == 1 and $cfg["file_favorites"] == 1 and $db_ar1[0]["log_fav"] == 1) ? " OR `act_type` LIKE 'favorite:short%' " : null; $bl_db .= ($cfg["live_module"] == 1 and $cfg["file_favorites"] == 1 and $db_ar1[0]["log_fav"] == 1) ? " OR `act_type` LIKE 'favorite:live%' " : null; $bl_db .= ($cfg["image_module"] == 1 and $cfg["file_favorites"] == 1 and $db_ar1[0]["log_fav"] == 1) ? " OR `act_type` LIKE 'favorite:image%' " : null; $bl_db .= ($cfg["audio_module"] == 1 and $cfg["file_favorites"] == 1 and $db_ar1[0]["log_fav"] == 1) ? " OR `act_type` LIKE 'favorite:audio%' " : null; $bl_db .= ($cfg["document_module"] == 1 and $cfg["file_favorites"] == 1 and $db_ar1[0]["log_fav"] == 1) ? " OR `act_type` LIKE 'favorite:doc%' " : null; $bl_db .= ($cfg["blog_module"] == 1 and $cfg["file_favorites"] == 1 and $db_ar1[0]["log_fav"] == 1) ? " OR `act_type` LIKE 'favorite:blog%' " : null; $bl_db .= ($cfg["video_module"] == 1 and $cfg["video_uploads"] == 1 and $db_ar1[0]["log_upload"] == 1) ? " OR `act_type` LIKE 'upload:video%' " : null; $bl_db .= ($cfg["short_module"] == 1 and $cfg["short_uploads"] == 1 and $db_ar1[0]["log_upload"] == 1) ? " OR `act_type` LIKE 'upload:short%' " : null; $bl_db .= ($cfg["live_module"] == 1 and $cfg["live_uploads"] == 1 and $db_ar1[0]["log_upload"] == 1) ? " OR `act_type` LIKE 'upload:live%' " : null; $bl_db .= ($cfg["image_module"] == 1 and $cfg["image_uploads"] == 1 and $db_ar1[0]["log_upload"] == 1) ? " OR `act_type` LIKE 'upload:image%' " : null; $bl_db .= ($cfg["audio_module"] == 1 and $cfg["audio_uploads"] == 1 and $db_ar1[0]["log_upload"] == 1) ? " OR `act_type` LIKE 'upload:audio%' " : null; $bl_db .= ($cfg["document_module"] == 1 and $cfg["document_uploads"] == 1 and $db_ar1[0]["log_upload"] == 1) ? " OR `act_type` LIKE 'upload:doc%' " : null; $bl_db .= ($cfg["blog_module"] == 1 and $db_ar1[0]["log_upload"] == 1) ? " OR `act_type` LIKE 'upload:blog%' " : null; $bl_db .= ($cfg["video_module"] == 1 and $cfg["file_rating"] == 1 and $db_ar1[0]["log_rating"] == 1) ? " OR `act_type` LIKE '%like:video%' " : null; $bl_db .= ($cfg["short_module"] == 1 and $cfg["file_rating"] == 1 and $db_ar1[0]["log_rating"] == 1) ? " OR `act_type` LIKE '%like:short%' " : null; $bl_db .= ($cfg["live_module"] == 1 and $cfg["file_rating"] == 1 and $db_ar1[0]["log_rating"] == 1) ? " OR `act_type` LIKE '%like:live%' " : null; $bl_db .= ($cfg["image_module"] == 1 and $cfg["file_rating"] == 1 and $db_ar1[0]["log_rating"] == 1) ? " OR `act_type` LIKE '%like:image%' " : null; $bl_db .= ($cfg["audio_module"] == 1 and $cfg["file_rating"] == 1 and $db_ar1[0]["log_rating"] == 1) ? " OR `act_type` LIKE '%like:audio%' " : null; $bl_db .= ($cfg["document_module"] == 1 and $cfg["file_rating"] == 1 and $db_ar1[0]["log_rating"] == 1) ? " OR `act_type` LIKE '%like:doc%' " : null; $bl_db .= ($cfg["blog_module"] == 1 and $cfg["file_rating"] == 1 and $db_ar1[0]["log_rating"] == 1) ? " OR `act_type` LIKE '%like:blog%' " : null; $bl_db .= ($cfg["video_module"] == 1 and $cfg["file_responses"] == 1 and $db_ar1[0]["log_responding"] == 1) ? " OR `act_type` LIKE '%response:video%' " : null; $bl_db .= ($cfg["short_module"] == 1 and $cfg["file_responses"] == 1 and $db_ar1[0]["log_responding"] == 1) ? " OR `act_type` LIKE '%response:short%' " : null; $bl_db .= ($cfg["live_module"] == 1 and $cfg["file_responses"] == 1 and $db_ar1[0]["log_responding"] == 1) ? " OR `act_type` LIKE '%response:live%' " : null; $bl_db .= ($cfg["image_module"] == 1 and $cfg["file_responses"] == 1 and $db_ar1[0]["log_responding"] == 1) ? " OR `act_type` LIKE '%response:image%' " : null; $bl_db .= ($cfg["audio_module"] == 1 and $cfg["file_responses"] == 1 and $db_ar1[0]["log_responding"] == 1) ? " OR `act_type` LIKE '%response:audio%' " : null; $bl_db .= ($cfg["document_module"] == 1 and $cfg["file_responses"] == 1 and $db_ar1[0]["log_responding"] == 1) ? " OR `act_type` LIKE '%response:doc%' " : null; $bl_db .= ($cfg["blog_module"] == 1 and $cfg["file_responses"] == 1 and $db_ar1[0]["log_responding"] == 1) ? " OR `act_type` LIKE '%response:blog%' " : null; $bl_db .= ($cfg["user_subscriptions"] == 1 and $db_ar1[0]["log_subscribing"] == 1) ? " OR `act_type` LIKE 'subscribes%' " : null; $bl_db .= ($cfg["user_follows"] == 1 and $db_ar1[0]["log_following"] == 1) ? " OR `act_type` LIKE 'follows%' " : null; $bl_db .= (($cfg["channel_comments"] == 1 or $cfg["file_comments"] == 1) and $db_ar1[0]["log_filecomment"] == 1) ? " OR `act_type` LIKE 'comments%' " : null; $sql = sprintf("SELECT `act_type`, `act_time`, `act_ip`, `act_visible`, `act_id` FROM `db_useractivity` WHERE `usr_id`='%s' AND `act_visible`='1' AND `act_deleted`='0' AND (%s) ORDER BY `act_id` DESC LIMIT %s;", $ch_uid, substr($bl_db, 3), $row["r_activity"]); $rs = self::$db_cache ? $db->CacheExecute($cfg['cache_channel_activity'], $sql) : $db->execute($sql); $db_ar2 = $rs->getrows(); $usr_user = self::$display_name != '' ? self::$display_name : (self::$channel_name != '' ? self::$channel_name : self::$user_name); $log_options = array(); $user_activity = array(); $user_actions = array(); foreach ($db_ar1[0] as $key => $val) { if (!is_numeric($key)) { $log_options[$key] = $val; } } $log_options["share_rating_bad"] = 1; if ($cfg["channel_bulletins"] == 1) { $log_options["public_bulletin"] = 1; $type = 'bulletin'; $islogged = self::getUserID() > 0 ? true : false; $html = '

    ' . $language["frontend.global.recent.activity"] . '

    ' . ($allow_cfg == 1 ? '
    ' : null) . '
    ' . VGenerate::simpleDivWrap('', 'comm-post-response', '') . ' ' . (($islogged and $allow_cfg == 1) ? ' ' : null); if ($allow_cfg == 1) { $pb_js = '$(".bulletin_text").focus(function(){var pb_val = $(this).val(); if(pb_val == "' . $usr_user . ': ") {$(this).val("");}});'; $pb_js .= '$(".bulletin_text").focusout(function(){var pb_val = $(this).val(); if(pb_val == "") {$(this).val("' . $usr_user . ': ");}});'; $pb_js .= '$(".post-bulletin-act").click(function(){'; $pb_js .= 'if($(".bulletin_text").val().length > 3 && $(".bulletin_text").val() != "' . $usr_user . ': "){'; $pb_js .= 'var do_bul="?a=postbulletin"; var do_form = $("#public-bulletin-form").serialize();'; $pb_js .= '$("#ntm").mask(" "); $.post(do_bul, do_form, function(data){ $("#comm-post-response").html(data); location.reload(); }); }'; $pb_js .= '});enterSubmit("#public-bulletin-form input", "#btn-1-bulletin_text");'; $pb_js .= '$(".hide-activity").click(function(){'; $pb_js .= ' $(".hide_activity_val").val($(this).attr("id")); do_action="?a=hideuseractivity"; do_form = $("#public-bulletin-form").serialize(); $("#liwrap-"+$(".hide_activity_val").val()).mask(" "); $.post(do_action, do_form, function(data){ $("#hide-activity-response").html(data); $("#liwrap-"+$(".hide_activity_val").val()).replaceWith(""); }); '; $pb_js .= '});'; $html .= VGenerate::declareJS('$(document).ready(function(){' . $pb_js . '});'); } } $html .= '
    '; $html .= '
      '; // var_dump($log_options); foreach ($db_ar2 as $key => $val) { $vals = explode(" ", $val[0]); $vabl = explode(":", $val[0]); $html .= $vabl[0] == 'bulletin' ? self::listUserActivities('public_bulletin', $log_options, $vabl, $usr_user, $val) : null; $html .= ($vabl[0] == 'upload' and $class_database->singleFieldValue('db_' . $vabl[1] . 'files', 'approved', 'file_key', $vabl[2]) == 1) ? self::listUserActivities('share_upload', $log_options, $vabl, $usr_user, $val) : null; $html .= $vabl[0] == 'like' ? self::listUserActivities('share_rating', $log_options, $vabl, $usr_user, $val) : null; $html .= $vabl[0] == 'dislike' ? self::listUserActivities('share_rating_bad', $log_options, $vabl, $usr_user, $val) : null; $html .= $vabl[0] == 'favorite' ? self::listUserActivities('share_fav', $log_options, $vabl, $usr_user, $val) : null; $html .= $vals[0] == 'comments' ? self::listUserActivities('share_filecomment', $log_options, $vals, $usr_user, $val) : null; $html .= $vabl[0] == 'response' ? self::listUserActivities('share_responding', $log_options, $vabl, $usr_user, $val) : null; $html .= $vals[0] == 'subscribes' ? self::listUserActivities('share_subscribing', $log_options, $vals, $usr_user, $val) : null; $html .= $vals[0] == 'follows' ? self::listUserActivities('share_following', $log_options, $vals, $usr_user, $val) : null; } $html .= '
    '; $html .= '
    '; return $html; } /* list specific user activities */ private static function listUserActivities($log_key, $log_options, $vals, $usr_user, $val) { $db = self::$db; $cfg = self::$cfg; $language = self::$language; $class_database = self::$dbc; $upage_id = self::$user_id; $allow_cfg = $upage_id == self::getUserID() ? 1 : 0; $act_time = VUserinfo::timeRange($val[1]); $act_hour = date('H:i', strtotime($val[1])); $act_visible = $val[3]; $act_id = $val[4]; $act_file = $language["frontend.global." . $vals[1][0] . ".a"]; switch ($log_key) { case "public_bulletin": $cmp_val = 'bulletin'; $ico_class = 'icon-comments'; $txt_comm = self::buildBulletinText($vals); $act_text_after = $vals[1]; break; case "share_upload": switch ($vals[1][0]) { case "l":$ic = 'icon-live'; break; case "v":$ic = 'icon-video'; break; case "s":$ic = 'icon-mobile'; break; case "i":$ic = 'icon-image'; break; case "a":$ic = 'icon-headphones'; break; case "d":$ic = 'icon-file'; break; case "b":$ic = 'icon-pencil2'; break; } $cmp_val = 'upload'; $ico_class = $ic; $act_text = ' ' . $language["upage.act.upload"] . ' ' . $act_file; $act_text_after = ''; break; case "share_fav": $cmp_val = 'favorite'; $ico_class = 'icon-heart'; $act_text = ' ' . $language["upage.act.favorite"] . ' ' . $act_file; $act_text_after = ''; break; case "share_rating": $cmp_val = 'like'; $ico_class = 'icon-thumbs-up'; $act_text = ' ' . $language["upage.act.like"] . ' ' . $act_file; $act_text_after = ''; break; case "share_rating_bad": $cmp_val = 'dislike'; $ico_class = 'icon-thumbs-up2'; $act_text = ' ' . $language["upage.act.dislike"] . ' ' . $act_file; $act_text_after = ''; break; case "share_filecomment": $ae = explode(":", $vals[2]); if ($ae[2] != '' and $ae[0] != 'channel') { $ft = $ae[0]; $fk = $ae[1]; $tt = $class_database->singleFieldValue('db_' . $ft . 'files', 'file_title', 'file_key', $fk); if ($tt == '') { return false; } $act_file = '' . VUserinfo::truncateString($tt, 50) . ''; $txt_comm = '
    ' . $class_database->singleFieldValue('db_' . $ft . 'comments', 'c_body', 'c_key', $ae[2]) . '
    '; } else { $i = sprintf("SELECT A.`usr_user`, A.`usr_key`, A.`usr_dname`, A.`ch_title` FROM `db_accountuser` A WHERE A.`usr_id`='%s' LIMIT 1;", $ae[1]); $r = self::$db_cache ? $db->CacheExecute($cfg['cache_channel_activity'], $i) : $db->execute($i); $usr_usr = $r->fields["usr_user"]; $usr_dname = $r->fields["usr_dname"]; $usr_title = $r->fields["ch_title"]; $usr_key = $r->fields["usr_key"]; $u = $usr_dname != '' ? $usr_dname : ($usr_title != '' ? $usr_title : $usr_usr); $act_text_after = (' $usr_usr]) . '" class="normal-link-col linkified">' . $u . '') . $language["upage.text.comm.pr"]; $txt_comm = '
    ' . $class_database->singleFieldValue('db_channelcomments', 'c_body', 'c_key', $ae[2]) . '
    '; } $cmp_val = 'comments'; $ico_class = 'icon-comment'; $act_text = ' ' . $language["upage.act.comment"] . ' ' . $act_file; break; case "share_responding": $act_visible = 1; $cmp_val = 'response'; $ico_class = 'icon-reply'; $f_info = self::getFileInfo($vals[2]); if (!isset($f_info["title"]) or $f_info["title"] == '') { $act_visible = 0; break; } $href_url = $cfg["main_url"] . '/' . VGenerate::fileHref(self::typeFromKey(VFiles::keyCheck($vals[2])), VFiles::keyCheck($vals[2]), $f_info["title"]); $act_text = str_replace('##TYPE##', $language["frontend.global." . $vals[1][0]], $language["upage.act.response"]); $act_text_after = ' ' . VUserinfo::truncateString($f_info["title"], 70) . ''; $f_info = self::getFileInfo($vals[3]); if (!isset($f_info["title"]) or $f_info["title"] == '') { $act_visible = 0; break; } $tmb_url = VGenerate::fileURL($tbl, $vals[3], 'thumb') . VBrowse::thumbnail(array($f_info["ukey"], $f_info["cache"]), $vals[3], $thumb_server = 0, $nr = 1, $force_type = false); $href_url = $cfg["main_url"] . '/' . VGenerate::fileHref(self::typeFromKey(VFiles::keyCheck($vals[3])), VFiles::keyCheck($vals[3]), $f_info["title"]); $txt_comm = '
    ' . $f_info[
    ' . VUserinfo::truncateString($f_info["title"], 70) . '
    ' . (VUserinfo::truncateString($f_info["description"], 350)) . '
    '; break; case "share_subscribing": case "share_following": $i = sprintf("SELECT A.`usr_user`, A.`usr_key`, A.`usr_dname`, A.`ch_title` FROM `db_accountuser` A WHERE A.`usr_user`='%s' LIMIT 1;", $vals[1]); $r = self::$db_cache ? $db->CacheExecute($cfg['cache_channel_activity'], $i) : $db->execute($i); $usr_usr = $r->fields["usr_user"]; $usr_dname = $r->fields["usr_dname"]; $usr_title = $r->fields["ch_title"]; $usr_key = $r->fields["usr_key"]; $u = $usr_dname != '' ? $usr_dname : ($usr_title != '' ? $usr_title : $usr_usr); $cmp_val = $log_key == 'share_subscribing' ? 'subscribes' : 'follows'; $ico_class = 'icon-users5'; $act_text = ' ' . ($log_key == 'share_subscribing' ? $language["upage.act.subscribe"] : $language["upage.act.follow"]) . ' '; $act_text_after = (' $vals[1]]) . '" class="normal-link-col linkified">' . $u . ''); break; } switch ($log_key) { case "share_upload": case "share_fav": case "share_rating": case "share_rating_bad": // case "share_responding": $f_info = self::getFileInfo($vals[2]); switch (self::typeFromKey(VFiles::keyCheck($vals[2]))) { 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; default:$tbl = 'video'; break; } $tmb_url = VGenerate::fileURL($tbl, $vals[2], 'thumb') . VBrowse::thumbnail(array($f_info["ukey"], $f_info["cache"]), $vals[2], $thumb_server = 0, $nr = 1, $force_type = false); $href_url = $cfg["main_url"] . '/' . VGenerate::fileHref(self::typeFromKey(VFiles::keyCheck($vals[2])), VFiles::keyCheck($vals[2]), $f_info["title"]); $txt_comm = '
    ' . $f_info[
    ' . VUserinfo::truncateString($f_info["title"], 70) . '
    ' . (VUserinfo::truncateString($f_info["description"], 350)) . '
    '; break; } $act_text = '' . $act_text . ''; $act_text_after = '' . $act_text_after . ''; $ht_cnd = ($log_options[$log_key] == 1 and $vals[0] == $cmp_val) ? 1 : 0; $txt = '
    ' . VAffiliate::affiliateBadge(((self::$usr_affiliate == 1 or self::$usr_partner == 1) ? 1 : 0), self::$affiliate_badge) . $usr_user . ($cmp_val == 'bulletin' ? ': ' : null) . ' ' . $act_text . ''; $txt .= $act_text_after; $txt .= '
    '; $close = null; if ($allow_cfg == 1) { $close = '
    '; } $html = ($act_visible == 1 and $ht_cnd == 1) ? '
  • ' . $txt . $close . '

    ' . $txt_comm . '
  • ' : null; return $html; } /* posting public bulletin */ public static function postBulletin() { $class_filter = self::$filter; $class_database = self::$dbc; $db = self::$db; $language = self::$language; $ch_cfg = self::$ch_cfg; $cfg = self::$cfg; $ch_uid = self::$user_id; $allow_cfg = $ch_uid == self::getUserID() ? 1 : 0; if ($allow_cfg == 0) { return; } $section = 'ch-user-activity'; $bull_text = $class_filter->clr_str($_POST["bulletin_text"]); $bull_time = date("Y-m-d H:i:s"); $db_arr = array("usr_id" => self::getUserID(), "act_type" => "bulletin:" . $bull_text, "act_time" => $bull_time, "act_ip" => $class_filter->clr_str($_SERVER[REM_ADDR])); $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; $_uid = $class_database->singleFieldValue('db_' . $db_tbl . 'files', 'usr_id', 'file_key', $file_key); $_sql = sprintf("SELECT `usr_id` FROM `db_%sfiles` WHERE `file_key`='%s' AND `privacy`%s AND `approved`='1' AND `deleted`='0' AND `active`='1' LIMIT 1;", $db_tbl, $file_key, ($_uid == $_SESSION["USER_ID"] ? "!='personal'" : "='public'")); $dbc = $db->execute($_sql); if ($cfg[$m . "_module"] == 1 and $dbc->fields["usr_id"] == $_uid) { $db_arr["act_type"] = "bulletin:" . $bull_text . ":" . $new_key; } } $do_db = ($bull_text != '' and strlen($bull_text) > 3) ? $class_database->doInsert('db_useractivity', $db_arr) : null; $db_id = $db->Insert_ID(); } /* building bulletin text */ private static function buildBulletinText($vals) { $cfg = self::$cfg; $class_database = self::$dbc; $ct = count($vals); if ($vals[$ct - 1] != '') { $v = explode("=", $vals[$ct - 1]); $t = $v[0]; $k = $v[1]; switch ($t) { 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; } $title = $class_database->singleFieldValue('db_' . $db_tbl . 'files', 'file_title', 'file_key', $k); } if ($title) { $f_info = self::getFileInfo($k); $tmb_url = $cfg["media_files_url"] . '/' . VBrowse::thumbnail($f_info["ukey"], $k, $thumb_server = 0, $nr = 1, $force_type = false); $tmb = '
    ' . $f_info[
    ' . VUserinfo::truncateString($f_info["title"], 70) . '
    ' . (VUserinfo::truncateString($f_info["description"], 350)) . '
    '; } return $tmb; } /* hiding activity */ public static function hideActivity() { $db = self::$db; $uid = self::getUserID(); $upage_id = self::$user_id; $allow_cfg = $upage_id == self::getUserID() ? 1 : 0; if ($allow_cfg == 0) { return; } $db_id = intval(substr($_POST["hide_activity"], 2)); $db_sel = sprintf("SELECT `act_type` FROM `db_useractivity` WHERE `usr_id`='%s' AND `act_id`='%s' LIMIT 1;", $uid, $db_id); $db_do = $db->execute($db_sel); $db_action = explode(":", $db_do->fields["act_type"]); $db_update = sprintf("UPDATE `db_useractivity` SET `act_visible`='0' WHERE `usr_id`='%s' AND `act_id`='%s' AND `act_visible`='1' LIMIT 1;", $uid, $db_id); $db_exec = $db_update; $db->execute($db_exec); } /* get title, descr from key */ private static function getFileInfo($fkey) { //global $db, $cfg; $db = self::$db; $cfg = self::$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) { $i = sprintf("SELECT A.`file_title`, A.`file_description`, A.`thumb_cache`, B.`usr_key` FROM `db_%sfiles` A, `db_accountuser` B WHERE A.`usr_id`=B.`usr_id` AND A.`file_key`='%s' LIMIT 1;", $key, $fkey); $rs = self::$db_cache ? $db->CacheExecute($cfg['cache_channel_activity'], $i) : $db->execute($i); if ($rs->fields["file_title"] != '') { return array("ukey" => $rs->fields["usr_key"], "title" => $rs->fields["file_title"], "description" => $rs->fields["file_description"], "type" => $key, "cache" => $rs->fields["thumb_cache"]); } } } } /* file type from key */ private static function typeFromKey($key) { $for = self::getFileInfo($key); return $for["type"][0]; } /* layout for manage channels */ public static function manageLayout() { $html = !isset($_GET["r"]) ? self::manage_general() : self::manage_art(); return $html; } /* new channel nav menu */ private static function nav_menu() { global $language, $class_filter, $cfg, $href; $_s = $class_filter->clr_str($_GET["s"]); $mobile = VHref::isMobile(); if (!$mobile_DISABLED) { $html = ' '; } $html = '
    '; return $html; } /* manage channel - general setup */ public static function manage_general() { global $href; $db = self::$db; $cfg = self::$cfg; $class_filter = self::$filter; $language = self::$language; $ch_cfg = self::$ch_cfg; $user_key = self::$user_key; $display_name = self::$channel_name; $info = self::getGeneralSetup(); $types = self::getChannelTypes(); $mobile = VHref::isMobile(); $types_html = null; $channel_url = VHref::channelURL(["username" => $_SESSION["USER_NAME"]]); if ($types->fields["ct_id"]) { while (!$types->EOF) { $types_html .= ''; $types->MoveNext(); } } $_s = $class_filter->clr_str($_GET["s"]); $html = '

    ' . $language["manage.channel.menu.general"] . '

    ' . self::nav_menu() . '
    ' . $channel_url . '

    '; $html .= ' '; $html .= VGenerate::swiperjs('tnav'); return $html; } /* manage channel - channel art */ public static function manage_art() { $db = self::$db; $cfg = self::$cfg; $class_filter = self::$filter; $language = self::$language; $mobile = VHref::isMobile(); $html = '

    ' . $language["manage.channel.menu.art"] . '

    ' . self::nav_menu() . '
    ' . self::manage_art_upload() . '
    ' . self::manage_art_own() . '
    ' . (!isset($_GET['r']) ? ' ' : null) . ' '; $html .= VGenerate::swiperjs('tnav'); return $html; } /* manage channel art - photo upload tab content */ private static function manage_art_upload() { $language = self::$language; $html = '

    ' . $language["manage.channel.upload.txt1"] . '


    ' . $language["manage.channel.upload.txt3"] . '

    '; return $html; } /* manage channel art - own uploaded files tab content */ private static function manage_art_own() { $cfg = self::$cfg; $user_key = self::$user_key; $ch_photos = self::$ch_photos; $base_dir = $cfg["profile_images_dir"] . '/' . $user_key . '/'; $base_url = $cfg["profile_images_url"] . '/' . $user_key . '/'; if (empty($ch_photos['list'])) { return; } $html = '
      '; foreach ($ch_photos['list'] as $nr => $file) { $filename = sprintf("%s-%s-small.jpg", $user_key, $file); $class = (($nr % 2) == 0) ? 'vs-column half' : 'vs-column half fit'; $html .= '
    • '; } $html .= '
        '; return $html; } /* manage channel art - gallery tab content */ private static function manage_art_gallery() { $cfg = self::$cfg; $user_key = self::$user_key; $ch_photos = self::$ch_photos; $base_dir = $cfg["profile_images_dir"] . '/gallery/'; $base_url = $cfg["profile_images_url"] . '/gallery/'; $html = '
          '; for ($i = 1; $i <= 12; $i++) { $filename = sprintf("%s-tmb.jpg", ($i >= 10 ? $i : '0' . $i)); $class = (($i % 3) == 0) ? 'vs-column thirds' : 'vs-column thirds fit'; $html .= '
        • '; } $html .= '
            '; return $html; } /* manage channel - delete image crop - confirmation html */ public static function html_delete_crop() { $cfg = self::$cfg; $class_filter = self::$filter; $language = self::$language; $user_key = self::$user_key; $image = $class_filter->clr_str($_GET["t"]); $filename = sprintf("%s-%s-src.jpg", $user_key, $image); $html = '

            ' . $language["manage.channel.del.ch.header"] . '

            ' . $language["manage.channel.delete.txt1"] . '
            ' . $language["manage.channel.delete.txt2"] . '

            ' . $language["frontend.global.cancel"] . '
            '; return $html; } /* manage channel - delete image crop - do delete operation */ private static function entry_delete_crop() { $cfg = self::$cfg; $db = self::$db; $class_filter = self::$filter; $language = self::$language; $user_key = self::$user_key; $ch_photos = self::$ch_photos; $deleted = 0; if ($_POST) { $image = $class_filter->clr_str($_POST["t"]); $filename = sprintf("%s-%s-src.jpg", $user_key, $image); $large_file = $cfg["profile_images_dir"] . '/' . $user_key . '/' . $user_key . '-' . $image . '-large.jpg'; $mid_file = $cfg["profile_images_dir"] . '/' . $user_key . '/' . $user_key . '-' . $image . '-mid.jpg'; $small_file = $cfg["profile_images_dir"] . '/' . $user_key . '/' . $user_key . '-' . $image . '-small.jpg'; $channel_file = $cfg["profile_images_dir"] . '/' . $user_key . '/' . $user_key . '-' . $image . '-ch.jpg'; $src_file = $cfg["profile_images_dir"] . '/' . $user_key . '/' . $user_key . '-' . $image . '-src.jpg'; $files = array($large_file, $mid_file, $small_file, $channel_file, $src_file); foreach ($files as $file) { if (file_exists($file)) { if (unlink($file)) { $deleted += 1; } } else { } } if ($deleted > 0) { $unset = 0; foreach ($ch_photos['list'] as $k => $file) { if ($file == $image) { unset($ch_photos['list'][$k]); $unset += 1; } } if ($unset > 0) { $ch_photos['list'] = array_values($ch_photos['list']); } if ($ch_photos['default'] == $file) { $ch_photos['default'] = $ch_photos['list'][0]; } if ($unset > 0) { $db->execute(sprintf("UPDATE `db_accountuser` SET `ch_photos`='%s', `ch_photos_nr`=`ch_photos_nr`+1 WHERE `usr_id`='%s' LIMIT 1;", serialize($ch_photos), self::getUserID())); } } } echo $deleted; } /* manage channel - adjust image crop */ public static function edit_crop() { $cfg = self::$cfg; $class_filter = self::$filter; $language = self::$language; $user_key = self::$user_key; $image = $class_filter->clr_str($_GET["t"]); $gallery = $_GET["do"] == 'edit-gcrop' ? true : false; if ($gallery) { $filename = sprintf("%s.jpg", ($image >= 10 ? $image : '0' . $image)); $tmp_file = $cfg["profile_images_dir"] . '/gallery/' . $filename; $tmp_img = $cfg["profile_images_url"] . '/gallery/' . $filename; } else { $filename = sprintf("%s-%s-src.jpg", $user_key, $image); $tmp_file = $cfg["profile_images_dir"] . '/' . $user_key . '/' . $filename; $tmp_img = $cfg["profile_images_url"] . '/' . $user_key . '/' . $filename; } if (file_exists($tmp_file) and filesize($tmp_file) > 0) { echo '

            ' . $language["manage.channel.edit.ch.header"] . '

    '; echo ' '; } } /* manage channel - channel modules */ public static function manage_modules() { $db = self::$db; $cfg = self::$cfg; $class_filter = self::$filter; $language = self::$language; $smarty = self::$smarty; $ch_cfg = self::$ch_cfg; $user_key = self::$user_key; $display_name = self::$channel_name; $mobile = VHref::isMobile(); $channel_url = VHref::channelURL(["username" => $display_name]); $html = '

    ' . $language["manage.channel.menu.modules"] . '

    ' . self::nav_menu() . '
    '; $html .= ' '; $html .= ' '; $html .= VGenerate::swiperjs('tnav'); return $html; } /* generate accordions for channel modules */ private static function ac_list($for) { $class_database = self::$dbc; $language = self::$language; $ch_cfg = self::$ch_cfg; $body = false; switch ($for) { case "home": $heading = $language["frontend.global.home"]; break; case "activity": $heading = $language["frontend.global.activity"]; $section = 'ch-user-activity'; $rowcfg = unserialize($class_database->singleFieldValue('db_accountuser', 'ch_rownum', 'usr_id', self::getUserID())); $body = '
    '; break; case "videos": case "shorts": case "live": case "broadcasts": case "images": case "audios": case "documents": case "blogs": $heading = $language["frontend.global." . $for[0] . ".p.c"]; break; case "playlists": $heading = $language["frontend.global.playlists"]; break; case "channels": $heading = $language["frontend.global.channels"]; $users = null; $rowcfg = unserialize($class_database->singleFieldValue('db_accountuser', 'ch_channels', 'usr_id', self::getUserID())); if (is_array($rowcfg["uc_names"]) and count($rowcfg["uc_names"]) > 0) { foreach ($rowcfg["uc_names"] as $unames) { $users .= $unames . "\n"; } } $body = '
    ' . VGenerate::basicInput('text', 'ch_user_channel_title', 'text-input wdmax', $rowcfg["uc_title"]) . ' ' . VGenerate::basicInput('textarea', 'ch_user_channel_names', 'textarea-input wdmax h100', $users) . '
    '; break; case "subscribers": $heading = $language["frontend.global.subscribers.cap"]; break; case "subscriptions": $heading = $language["subnav.entry.sub"]; break; case "followers": $heading = $language["frontend.global.followers.cap"]; break; case "following": $heading = $language["frontend.global.following.cap"]; break; case "discussion": case "comments": $heading = $language["subnav.entry.comments"]; $body = '

    '; break; case "about": $heading = $language["frontend.global.about"]; $ch_descr = $class_database->singleFieldValue('db_accountuser', 'ch_descr', 'usr_id', self::getUserID()); $rowcfg = unserialize($class_database->singleFieldValue('db_accountuser', 'ch_links', 'usr_id', self::getUserID())); $body = '
    '; break; } $input_name = 'channel_module_' . $for; $html = '
    • ' . $heading . ' ' . ($body ? ' ' : null) . '
      ' . ($body ? ' ' : null) . '
    '; return $html; } /* post/save channel configurations */ public static function postChanges($for) { $db = self::$db; $class_database = self::$dbc; $class_filter = self::$filter; $ch_cfg = self::$ch_cfg; $language = self::$language; $update = false; $links = 0; if (!$_POST) { return; } switch ($for) { case "ch_setup": $ch_array = VArraySection::getArray("channel_setup_tab"); $ch_cfg["ch_visible"] = (int) $_POST["ch_visible"] == 1 ? 1 : 0; $update = true; $updated = 0; break; case "ch_modules": /* update activity */ if (isset($_POST["ch_user_activity_cfglist"])) { $ch_activity = (int) $_POST["ch_user_activity_cfglist"]; $sel_name = str_replace("-", "_", 'ch-user-activity'); $rowcfg = unserialize($class_database->singleFieldValue('db_accountuser', 'ch_rownum', 'usr_id', self::getUserID())); $rowcfg["r_activity"] = $ch_activity > 0 ? $ch_activity : $rowcfg['r_activity']; $db->execute(sprintf("UPDATE `db_accountuser` SET `ch_rownum`='%s' WHERE `usr_id`='%s' LIMIT 1;", serialize($rowcfg), self::getUserID())); if ($db->Affected_Rows() > 0) { $updated += 1; } } /* update featured channels */ if (isset($_POST["ch_user_channel_title"]) or isset($_POST["ch_user_channel_names"])) { $_db = array(); $_users = array(); $ch_title = $class_filter->clr_str($_POST["ch_user_channel_title"]); $ch_names = explode("\n", $class_filter->clr_str($_POST["ch_user_channel_names"])); $_db["uc_title"] = $ch_title; if (count($ch_names) > 0) { foreach ($ch_names as $key => $uname) { $uname = str_replace(chr(13), "", $uname); if (VUserinfo::existingUsername($uname) and !in_array($uname, $_users)) { $_users[$key] = $uname; } } $_db["uc_names"] = array_values(array_unique($_users)); $db->execute(sprintf("UPDATE `db_accountuser` SET `ch_channels`='%s' WHERE `usr_id`='%s' LIMIT 1;", serialize($_db), self::getUserID())); if ($db->Affected_Rows() > 0) { $updated += 1; } } } /* update comment permissions */ if (isset($_POST["ch_comm_perm"])) { $ch_comm_perm = $class_filter->clr_str($_POST["ch_comm_perm"]); $ch_cfg["ch_comm_perms"] = $ch_comm_perm; $update = true; } /* update comment spam reporting */ if (isset($_POST["ch_comm_spam"])) { $ch_comm_spam = (int) $_POST["ch_comm_spam"]; $ch_cfg["ch_comm_spam"] = $ch_comm_spam; $update = true; } /* update channel description */ if (isset($_POST["ch_descr"])) { $ch_descr = $class_filter->clr_str($_POST["ch_descr"]); $db->execute(sprintf("UPDATE `db_accountuser` SET `ch_descr`='%s' WHERE `usr_id`='%s' LIMIT 1;", $ch_descr, self::getUserID())); if ($db->Affected_Rows() > 0) { $updated += 1; } } /* update personal details in channel page */ if ((int) $_POST["ch_profile_details"] != $ch_cfg["ch_profile_details"]) { $profile_details = (int) $_POST["ch_profile_details"]; $ch_cfg["ch_profile_details"] = $profile_details; $update = true; } /* update custom links */ for ($i = 0; $i < 4; $i++) { if ($_POST["channel_link_title"][$i] != '' or $_POST["channel_link_url"][$i] != '') { $ch_links[] = array(); if ($_POST["channel_link_title"][$i] != '' and $_POST["channel_link_url"][$i] == '') { return VGenerate::noticeTpl('', $language["manage.channel.error.2"], ''); } elseif ($_POST["channel_link_url"][$i] != '' and $_POST["channel_link_title"][$i] == '') { return VGenerate::noticeTpl('', $language["manage.channel.error.3"], ''); } $url = parse_url($class_filter->clr_str($_POST["channel_link_url"][$i])); if (!isset($url['scheme'])) { $url['scheme'] = 'http'; } if ($url['scheme'] == 'http' or $url['scheme'] == 'https') { $host = $url['host']; if (!$host) { return VGenerate::noticeTpl('', $language["manage.channel.error.4"], ''); } $ch_links[$i]['title'] = $class_filter->clr_str($_POST["channel_link_title"][$i]); $ch_links[$i]['url'] = $url['scheme'] . '://' . $host . $url['path'] . ($url['query'] != '' ? '?' . $url['query'] : null); } else { return VGenerate::noticeTpl('', $language["manage.channel.error.1"], ''); } $links += 1; } } /* update module sections */ $mod = array('ch_m_home' => 'channel_module_home', 'ch_m_activity' => 'channel_module_activity', 'ch_m_videos' => 'channel_module_videos', 'ch_m_shorts' => 'channel_module_shorts', 'ch_m_live' => 'channel_module_live', 'ch_m_images' => 'channel_module_images', 'ch_m_audios' => 'channel_module_audios', 'ch_m_documents' => 'channel_module_documents', 'ch_m_playlists' => 'channel_module_playlists', 'ch_m_blogs' => 'channel_module_blogs', 'ch_m_channels' => 'channel_module_channels', 'ch_m_subscribers' => 'channel_module_subscribers', 'ch_m_subscriptions' => 'channel_module_subscriptions', 'ch_m_followers' => 'channel_module_followers', 'ch_m_following' => 'channel_module_following', 'ch_m_discussion' => 'channel_module_discussion', 'ch_m_about' => 'channel_module_about', ); foreach ($mod as $m => $module) { $ch_cfg[$m] = isset($_POST[$module . "_check"]) ? 1 : 0; $update = true; } break; case "ch_art": if (isset($_GET["do"])) { switch ($_GET["do"]) { case "upload": self::processUpload(); break; case "save": self::saveUpload(); break; case "save_crop": $crop_id = $class_filter->clr_str($_GET["t"]); self::saveUpload($crop_id); break; case "save_default": $crop_id = $class_filter->clr_str($_GET["t"]); self::saveDefault($crop_id); break; case "delete": self::entry_delete_crop(); break; } } } if ($update) { $ch_array[0]["ch_cfg"] = serialize($ch_cfg); $success = $class_database->entryUpdate('db_accountuser', $ch_array[0]) ? VGenerate::noticeTpl('', '', $language["notif.success.request"]) : null; if ($success) { $updated += 1; } } if ($links > 0) { $db->execute(sprintf("UPDATE `db_accountuser` SET `ch_links`='%s' WHERE `usr_id`='%s' LIMIT 1;", serialize($ch_links), self::getUserID())); if ($db->Affected_Rows() > 0) { $updated += 1; } } if ($updated > 0) { return VGenerate::noticeTpl('', '', $language["notif.success.request"]); } return false; } /* set cropped image as default */ private static function saveDefault($crop_id) { $db = self::$db; $ch_photos = self::$ch_photos; $language = self::$language; if ($_POST) { $ch_photos['default'] = $crop_id; $db->execute(sprintf("UPDATE `db_accountuser` SET `ch_photos`='%s', `ch_photos_nr`=`ch_photos_nr`+1 WHERE `usr_id`='%s' LIMIT 1;", serialize($ch_photos), self::getUserID())); if ($db->Affected_Rows() > 0) { echo VGenerate::noticeTpl('', '', $language["notif.success.request"]); } } } /* process new photo upload */ private static function processUpload() { $cfg = self::$cfg; $class_filter = self::$filter; $language = self::$language; $user_key = self::$user_key; echo '1'; //the weirdest fix EVER, but jquery form plugin fails without it... $upload_file_name = $class_filter->clr_str($_FILES["fedit_image"]["tmp_name"]); list($width, $height) = getimagesize($upload_file_name); $upload_file_size = (int) $_FILES["fedit_image"]["size"]; $upload_file_limit = $cfg["channel_bg_max_size"] * 1024 * 1024; $upload_file_type = strtoupper(VFileinfo::getExtension($_FILES["fedit_image"]["name"])); $upload_allowed = explode(',', strtoupper($cfg["channel_bg_allowed_extensions"])); $error_message = $upload_file_size > $upload_file_limit ? $language["account.error.filesize"] : null; $error_message = ($width < 1920 and $height < 1080) ? $language["manage.channel.upload.err1"] : $error_message; $error_message = ($width > 2560 and $height > 1440) ? $language["manage.channel.upload.err2"] : $error_message; $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 == '') { $tmp_file = $cfg["profile_images_dir"] . '/' . $user_key . '/tmp_' . $user_key . '.jpg'; $new_file = $cfg["profile_images_dir"] . '/' . $user_key . '/new_' . $user_key . '.jpg'; $tmp_img = $cfg["profile_images_url"] . '/' . $user_key . '/tmp_' . $user_key . '.jpg'; if (file_exists($tmp_file)) {@unlink($tmp_file);} if (file_exists($new_file)) {@unlink($new_file);} if (rename($upload_file_name, $tmp_file)) { chmod($tmp_file, 0644); if (filesize($tmp_file) > 0) { echo '

    ' . $language["manage.channel.edit.ch.header"] . '


    '; echo ' '; } } } } //resize and crop image by center private static function resize_crop_image($max_width, $max_height, $source_file, $dst_file, $quality = 99) { $imgsize = getimagesize($source_file); $width = $imgsize[0]; $height = $imgsize[1]; $mime = $imgsize['mime']; switch ($mime) { case 'image/gif': $image_create = "imagecreatefromgif"; $image = "imagegif"; break; case 'image/png': $image_create = "imagecreatefrompng"; $image = "imagepng"; $quality = 9; break; case 'image/jpeg': $image_create = "imagecreatefromjpeg"; $image = "imagejpeg"; $quality = 99; break; default: return false; break; } $dst_img = imagecreatetruecolor($max_width, $max_height); $src_img = $image_create($source_file); $width_new = $height * $max_width / $max_height; $height_new = $width * $max_height / $max_width; //if the new width is greater than the actual width of the image, then the height is too large and the rest cut off, or vice versa if ($width_new > $width) { //cut point by height $h_point = (($height - $height_new) / 2); //copy image imagecopyresampled($dst_img, $src_img, 0, 0, 0, $h_point, $max_width, $max_height, $width, $height_new); } else { //cut point by width $w_point = (($width - $width_new) / 2); imagecopyresampled($dst_img, $src_img, 0, 0, $w_point, 0, $max_width, $max_height, $width_new, $height); } $image($dst_img, $dst_file, $quality); if ($dst_img) { imagedestroy($dst_img); } if ($src_img) { imagedestroy($src_img); } } /* process/save cropped image */ private static function saveUpload($crop_id = false) { $cfg = self::$cfg; $db = self::$db; $ch_photos = self::$ch_photos; $class_filter = self::$filter; $language = self::$language; $user_key = self::$user_key; $crop_update = true; $crop_data = $_POST ? $class_filter->clr_str($_POST['crop_data']) : false; if ($_POST and $crop_data and $crop_update) { $crop_data = str_replace(array('data:', 'base64,'), '', $crop_data); $arr = explode(';', $crop_data); $ext = (isset($arr['0'])) ? self::mime_to_ext($arr['0']) : false; $data = (isset($arr['1'])) ? base64_decode($arr['1']) : false; if ($ext && $data) { $timestamp = (!$crop_id || $crop_id < 24) ? time() : $crop_id; $new_file = $cfg["profile_images_dir"] . '/' . $user_key . '/new_' . $user_key . '.jpg'; //$tmp_file = (($crop_id < 24 or ($_POST and $_GET["do"] != 'save')) ? $cfg["profile_images_dir"].'/gallery/'.($crop_id >= 10 ? $crop_id : '0'.$crop_id).'.jpg' : $cfg["profile_images_dir"].'/'.$user_key.'/tmp_'.$user_key.'.jpg'); $tmp_file = ($crop_id < 24 and $_GET["do"] != 'save') ? $cfg["profile_images_dir"] . '/gallery/' . ($crop_id >= 10 ? $crop_id : '0' . $crop_id) . '.jpg' : $cfg["profile_images_dir"] . '/' . $user_key . '/tmp_' . $user_key . '.jpg'; $large_file = $cfg["profile_images_dir"] . '/' . $user_key . '/' . $user_key . '-' . $timestamp . '-large.jpg'; $mid_file = $cfg["profile_images_dir"] . '/' . $user_key . '/' . $user_key . '-' . $timestamp . '-mid.jpg'; $small_file = $cfg["profile_images_dir"] . '/' . $user_key . '/' . $user_key . '-' . $timestamp . '-small.jpg'; $channel_file = $cfg["profile_images_dir"] . '/' . $user_key . '/' . $user_key . '-' . $timestamp . '-ch.jpg'; $src_file = $cfg["profile_images_dir"] . '/' . $user_key . '/' . $user_key . '-' . $timestamp . '-src.jpg'; file_put_contents($new_file, $data); $image = VImage::load($new_file); $image->resizeToWidth_base(2120); $image->save($large_file); $image->resizeToWidth_base(1057); $image->save($mid_file); $image->resizeToWidth_base(532); $image->save($small_file); if (!$crop_id || $crop_id < 24) { if ($crop_id < 24) { copy($tmp_file, $src_file); } else { rename($tmp_file, $src_file); } if (filesize($small_file) > 0) { $ch_photos['default'] = $timestamp; $ch_photos['list'][] = $timestamp; $db->execute(sprintf("UPDATE `db_accountuser` SET `ch_photos`='%s', `ch_photos_nr`=`ch_photos_nr`+1 WHERE `usr_id`='%s' LIMIT 1;", serialize($ch_photos), self::getUserID())); if ($db->Affected_Rows() > 0) { echo VGenerate::noticeTpl('', '', $language["notif.success.request"]); if (file_exists($new_file)) { unlink($new_file); } } } } else { //if (file_exists($new_file)) { if (filesize($small_file) > 0) { $db->execute(sprintf("UPDATE `db_accountuser` SET `ch_photos_nr`=`ch_photos_nr`+1 WHERE `usr_id`='%s' LIMIT 1;", self::getUserID())); echo VGenerate::noticeTpl('', '', $language["notif.success.request"]); unlink($new_file); } } self::resize_crop_image(560, 224, $src_file, $channel_file); } } } /* get extension from mime type */ private static function mime_to_ext($mime) { $mimes = array( 'image/jpeg' => 'jpg', 'image/pjpeg' => 'jpg', 'image/png' => 'png', 'image/x-png' => 'png', 'image/tiff' => 'tif', 'image/gif' => 'gif', ); return (isset($mimes[$mime])) ? $mimes[$mime] : false; } /* get general setup values */ private static function getGeneralSetup() { $db = self::$db; $sql = sprintf("SELECT `ch_title`, `ch_tags`, `ch_descr`, `ch_type` FROM `db_accountuser` WHERE `usr_id`='%s' LIMIT 1;", self::getUserID()); $res = $db->execute($sql); return $res; } /* get channel types */ private static function getChannelTypes() { $db = self::$db; $sql = sprintf("SELECT `ct_id`, `ct_name` FROM `db_categories` WHERE `ct_type`='channel' AND `ct_active`='1';"); $res = self::$db_cache ? $db->CacheExecute(self::$cfg['cache_channel_channeltypes'], $sql) : $db->execute($sql); return $res; } /* my user id */ private static function getUserID() { return (int) $_SESSION["USER_ID"]; } /* channel page header css */ private static function CSS() { $css = null; $cfg = self::$cfg; $ch_photos = self::$ch_photos; $header_image = is_file($cfg["profile_images_dir"] . '/' . self::$user_key . '/' . self::$user_key . '-' . $ch_photos['default'] . '-large.jpg') ? true : false; $css .= $header_image ? '.tpl_channel .crop-height{height:calc((100vw - 240px)/6.2 - 1px)}' : null; $css .= '.bg-channel-image{' . ($header_image ? 'background-image: url(' . $cfg["profile_images_url"] . '/' . self::$user_key . '/' . self::$user_key . '-' . $ch_photos['default'] . '-large.jpg?t=' . self::$ch_photos_nr . ');' : null) . '} @media(max-width:1250px){' . ($header_image ? '.tpl_channel .crop-height{height: calc(16.1290322581vw - 1px)}' : null) . '} @media(max-width:768px){.bg-channel-image{' . ($header_image ? 'background-image: url(' . $cfg["profile_images_url"] . '/' . self::$user_key . '/' . self::$user_key . '-' . $ch_photos['default'] . '-mid.jpg?t=' . self::$ch_photos_nr . ');' : null) . ($header_image ? '.tpl_channel .crop-height{height:calc((100vw - -50px)/6.2 - 1px)}' : null) . '}}'; return $css; } /* return string before string */ private static function strbefore($string, $substring) { $pos = strpos($string, $substring); if ($pos === false) { return $string; } else { return (substr($string, 0, $pos)); } } }