' . $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 .= '
';
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 = '

';
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 = '
';
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 = '

';
}
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() . '
';
$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() . '
' . self::manage_art_gallery() . '
' . (!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 = '
';
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 = '
';
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 '