';
$html .= '
';
$html .= '
';
$html .= VGenerate::simpleDivWrap('entry-title ct-bullet-label place-left right-padding10 link', '', $_title, '');
$html .= '
';
$html .= '
';
$html .= VGenerate::simpleDivWrap('entry-type ct-bullet-label place-left greyed-out ', '', $_info, '');
$html .= VGenerate::simpleDivWrap('entry-owner ct-bullet-label place-left', '', '
' . $language["frontend.global.by"] . ' ' . $_user_show . ' ', '');
$html .= '
';
$html .= '
';
$html .= ' ';
$html .= ' ';
$html .= '
';
$html .= '
';
$html .= self::fileDetails('block', $type, $entry_id, $info_array);
$html .= '
';
$html .= '';
$do = $do + 1;
@$res->MoveNext();
}
$html .= '';
$html .= $db_count > 0 ? '
' . $paging_links . $results_text . '
' . $language["files.text.none"] . '
';
$html .= '';
$js .= '$(document).ready(function(){var clone = $("#paging-top").clone(true); $("#paging-top").detach(); $(clone).insertBefore("#open-close-links");});';
$js .= '
function brs() {
' . ($type[0] == 'b' ? 'setTimeout( function() { jQuery(".fancybox-inner").css({height:"auto",width:"auto"}); }, 2000);' : null) . '
}
function blogload(file_key, usr_key) {
dst = $(".responsive-accordion-panel.active.p-msover a.blogload");
$.get(current_url + "' . VHref::getKey("be_files") . '" + "?do=blogload&f="+file_key+"&u="+usr_key , function( data ) {
dst.replaceWith(data);
$(".responsive-accordion-panel.active.p-msover").css("height", "auto");
$(".responsive-accordion-panel.active.p-msover .update-blog-btn").removeClass("hidden");
thisresizeDelimiter();
});
}
$(".update-blog-entry").on("click", function() {
ht = $(".responsive-accordion-panel.active.p-msover .d-editable").html();
ukey = $(this).attr("rel-usr");
fkey = $(this).attr("rel-file");
$(".responsive-accordion-panel.active.p-msover").mask(" ");
$.post( current_url + "' . VHref::getKey("be_files") . '" + "?do=blogsave", { u: ukey, f: fkey, blog_html: encodeURIComponent(ht) }, function(data){
$(".responsive-accordion-panel.active.p-msover .blog-load-response").html(data);
$(".responsive-accordion-panel.active.p-msover").unmask();
});
});
';
/* file players popup box */
$js .= '$("a.popup").on("click", function(e){ e.preventDefault();';
$js .= '$("#view-player").replaceWith("");';
$js .= 'var popupid = $(this).attr("rel");';
$js .= 'var filekey = $(this).attr("rel-fkey");';
$js .= 'var userkey = $(this).attr("rel-ukey");';
$js .= 'var filehd = $(this).attr("rel-hd");';
$js .= 'var filepv = (typeof $(this).attr("rel-pv") != "undefined" ? $(this).attr("rel-pv") : 0);';
$js .= 'var mh = 0;';
$js .= 'if($(this).hasClass("manage-ads")){';
$js .= 'var url = current_url + menu_section + "?do=manage-ads&type=' . $type . '&file_key="+filekey;';
$js .= '} else if($(this).hasClass("manage-banners")) {';
$js .= 'var url = current_url + menu_section + "?do=manage-banners&type=' . $type . '&file_key="+filekey;';
$js .= '} else if($(this).hasClass("manage-subs")) {';
$js .= 'var url = current_url + menu_section + "?do=manage-subs&type=' . $type . '&file_key="+filekey;';
$js .= '} else if($(this).hasClass("conversion-log")) {';
$js .= 'var url = current_url + menu_section + "?do=conversion-log&type=' . $type . '&file_key="+filekey;';
$js .= '} else if($(this).hasClass("server-paths")) {';
$js .= 'var url = current_url + menu_section + "?do=server-paths&type=' . $type . '&file_key="+filekey;';
$js .= '} else {';
$js .= 'mh = 1; var url = current_url + menu_section + "?p=1&' . $type[0] . '=1&type=' . $type . '§ion=backend&usr_key=" + userkey + "&file_key=" + filekey + "&hd="+ filehd + "&pv=" + filepv;';
$js .= '}';
if ($type[0] == 'i') {
// $js .= '$(".fancy-img").fancybox({margin: 10});';
}
$js .= 'if (mh == 1) {$.fancybox.open({ afterLoad: brs(), wrapCSS: "be-player", width: "auto", minWidth: "80%", "height": "100vh", type: "ajax", margin: 10, href: url });} else {$.fancybox.open({ minWidth: "90%", type: "ajax", margin: 10, href: url });}';
$js .= '});';
/* declare JS */
$html .= VGenerate::declareJS($js);
return $html;
}
/* load players */
public function playerLoader()
{
global $cfg, $class_filter, $language, $class_database, $db;
$type = $class_filter->clr_str($_GET["type"]);
$section = $class_filter->clr_str($_GET["section"]);
$usr_key = $class_filter->clr_str($_GET["usr_key"]);
$file_key = $class_filter->clr_str($_GET["file_key"]);
$is_hd = intval($_GET["hd"]);
/* player width and height */
$_p = VPlayers::playerInit('backend');
$_width = $_p[1];
$_height = $_p[2];
$i = $db->execute(sprintf("SELECT `thumb_cache`, `embed_key`, `embed_src`, `embed_url`, `old_file_key` FROM `db_%sfiles` WHERE `file_key`='%s' LIMIT 1;", $type, $file_key));
$embed_key = $i->fields["embed_key"];
$embed_src = $i->fields["embed_src"];
$embed_url = $i->fields["embed_url"];
$old_key = $i->fields["old_file_key"];
$thumb_cache = $i->fields["thumb_cache"];
$thumb_cache = $thumb_cache > 1 ? $thumb_cache : null;
$tmb_url = VGenerate::thumbSigned($type, $file_key, array($usr_key, $thumb_cache), 0, ($type[0] == 'a' ? 0 : 1));
switch ($type[0]) {
case "v": //video players
case "s": //short players
case "l": //live players
if ($embed_src == 'local') {
switch ($cfg["video_player"]) {
case "vjs":
$p_ht = VGenerate::declareJS(VPlayers::VJSJS($section, $usr_key, $file_key, $is_hd, '', ''));
break;
}
} else {
$info = array();
$info["key"] = $embed_key;
$info["url"] = $embed_url;
$p_ht = VPlayers::playerEmbedCodes($embed_src, $info, $_width, $_height, '', 1);
}
break;
case "i": //image players
switch ($cfg["image_player"]) {
case "jq":
$gs = $old_key == 1 ? $file_key : md5($cfg["global_salt_key"] . $file_key);
$img_url = VGenerate::thumbSigned(array("type" => "image", "server" => "upload", "key" => '/' . $usr_key . '/i/' . $gs . '.jpg'), array($file_key, $gs), array($usr_key, $thumb_cache), 0, 1);
$p_ht = '
';
break;
case "jw":
$p_ht = VGenerate::declareJS(VPlayers::JWJS($section, $usr_key, $file_key, 0, '', ''));
break;
case "flow":
$p_ht = VGenerate::declareJS(VPlayers::FPJS($section, $usr_key, $file_key, 0, '', ''));
break;
}
break;
case "a": //audio players
switch ($cfg["audio_player"]) {
case "vjs":
$p_ht = VGenerate::declareJS(VPlayers::VJSJS($section, $usr_key, $file_key, 0, '', ''));
break;
case "jw":
$p_ht = VGenerate::declareJS(VPlayers::JWJS($section, $usr_key, $file_key, 0, '', ''));
break;
case "flow":
$p_ht = VGenerate::declareJS(VPlayers::FPJS($section, $usr_key, $file_key, 0, '', ''));
break;
}
break;
case "d": //document players
switch ($cfg["document_player"]) {
case "free":
$p_ht = '
' . VGenerate::declareJS(VPlayers::FREEJS($section, $usr_key, $file_key, 0, '', '')) . '
';
break;
case "reader":
$p_ht = VGenerate::declareJS(VPlayers::DOCJS($section, $usr_key, $file_key, 0, '', ''));
break;
}
break;
case "b": //blog loader
$href_key = 'blogs';
$blog_tpl = $cfg["media_files_dir"] . '/' . $usr_key . '/b/' . $file_key . '.tplb';
$blog_html = null;
if (file_exists($blog_tpl)) {
$blog_html = file_get_contents($blog_tpl);
$media = VGenerate::extract_text($blog_html);
if ($media[0]) {
foreach ($media as $media_entry) {
$a = explode("_", $media_entry);
$mtype = $a[1];
$mkey = $a[2];
/* embed code player sizes */
$ps = array();
$ps[0]["w"] = '50%';
$ps[0]["h"] = 500;
$ps[1]["w"] = 640;
$ps[1]["h"] = 360;
$ps[2]["w"] = 853;
$ps[2]["h"] = 480;
$ps[3]["w"] = 1280;
$ps[3]["h"] = 720;
switch ($mtype[0]) {
case "l":
case "s":
case "v": //embed code for video and audio is generated from within player cfg after initialization (class.players.php)
$vi = sprintf("SELECT A.`file_type`, A.`embed_src`, A.`embed_key`, A.`embed_url`, B.`usr_key` FROM `db_%sfiles` A, `db_accountuser` B WHERE A.`usr_id`=B.`usr_id` AND A.`file_key`='%s' LIMIT 1;", $mtype, $mkey);
$mrs = $db->execute($vi);
$msrc = $mrs->fields["file_type"];
$membed_src = $mrs->fields["embed_src"];
$membed_key = $mrs->fields["embed_key"];
$membed_url = $mrs->fields["embed_url"];
$mukey = $mrs->fields["usr_key"];
if ($msrc == 'embed') {
$mec = VPlayers::playerEmbedCodes($membed_src, array("key" => $membed_key, "url" => $membed_url), $ps[0]["w"], $ps[0]["h"]);
} else {
$mec = '
';
}
break;
case "a": //embed code for video and audio is generated from within player cfg after initialization (class.players.php)
$mec = '
';
break;
case "d": //embed code for documents is generated from within player cfg after page load (class.players.php)
$vi = sprintf("SELECT A.`file_type`, A.`thumb_cache`, A.`embed_src`, A.`embed_key`, B.`usr_key` FROM `db_docfiles` A, `db_accountuser` B WHERE A.`usr_id`=B.`usr_id` AND A.`file_key`='%s' LIMIT 1;", $mkey);
$mrs = $db->execute($vi);
$mukey = $mrs->fields["usr_key"];
$mthumb_cache = $mrs->fields["thumb_cache"];
$mthumb_cache = $mthumb_cache > 1 ? $mthumb_cache : null;
$mdoc = VGenerate::thumbSigned(array("type" => "doc", "server" => "upload", "key" => '/' . $mukey . '/d/' . $mkey . '.pdf'), $mkey, array($mukey, $mthumb_cache), 0, 1);
$mec = '
';
break;
case "i":
$vi = sprintf("SELECT A.`file_type`, A.`thumb_cache`, A.`embed_src`, A.`embed_key`, B.`usr_key` FROM `db_imagefiles` A, `db_accountuser` B WHERE A.`usr_id`=B.`usr_id` AND A.`file_key`='%s' LIMIT 1;", $mkey);
$mrs = $db->execute($vi);
$mukey = $mrs->fields["usr_key"];
$mthumb_cache = $mrs->fields["thumb_cache"];
$mthumb_cache = $mthumb_cache > 1 ? $mthumb_cache : null;
switch ($cfg["image_player"]) {
case "jq":
$_js = null;
$image_link = VGenerate::thumbSigned($mtype, $mkey, array($mukey, $mthumb_cache), 0, 1, 0);
$mec = ' ';
break;
}
break;
}
$blog_html = str_replace("[" . $media_entry . "]", $mec, $blog_html);
}
}
}
$p_ht = '' . $blog_html . '
';
break;
}
/* player wrapper */
$divdata = null;
$dim_unit_w = (substr($_width, -1) == '%') ? null : 'px';
$dim_unit_h = (substr($_height, -1) == '%') ? null : 'px';
$dim = 'width: ' . $_width . $dim_unit_w . '; height: ' . $_height . $dim_unit_h . ';';
$html .= '';
$html .= (($type[0] == 'v' or $type[0] == 's' or $type[0] == 'l') and $cfg["video_player"] == 'vjs' and $embed_src == 'local') ? ' ' : null;
$html .= ($type[0] == 'a' and $cfg["audio_player"] == 'vjs') ? '<' . $type . ' id="view-player-' . $file_key . '" preload="none" class="video-js vjs-default-skin vjs-big-play-centered" data-setup="{}" />' : null;
$html .= $p_ht;
$html .= '
'; //PLAYER HERE
$html .= VGenerate::declareJS('$(document).ready(function(){' . $js . '});');
echo $html;
}
/* manage subtitles */
public function subsManager($file_key)
{
global $db, $cfg, $language, $class_database, $class_filter, $smarty;
$type = $class_filter->clr_str($_GET["type"]);
$dbt = $cfg[$type . "_player"] == 'vjs' ? 'vjs_subs' : ($cfg[$type . "_player"] == 'jw' ? 'jw_subs' : 'fp_subs');
$title = $class_database->singleFieldValue('db_' . $type . 'files', 'file_title', 'file_key', $file_key);
$subs = $class_database->singleFieldValue('db_' . $type . 'subs', $dbt, 'file_key', $file_key);
$_cfg = $subs != '' ? unserialize($subs) : null;
$sub_dir = $cfg["main_dir"] . '/f_data/data_subtitles/';
$sub_url = $cfg["main_url"] . '/f_data/data_subtitles/';
$sub_files = array_values(array_diff(scandir($sub_dir), array('..', '.', '.htaccess')));
if ($sub_files[0]) {
$s = 0;
foreach ($sub_files as $k => $sub) {
$md = md5($sub);
if ($cfg[$type . "_player"] == 'jw' or $cfg[$type . "_player"] == 'vjs') {
$sht .= '';
$sht .= '
' . $sub . '
';
$sht .= '
';
$sht .= '
';
$sht .= '
';
$sht .= '
';
} else {
$sht .= VGenerate::simpleDivWrap('row top-padding5 subs-list icheck-box', '', '' . $sub . ' ' . (($subs != '' and $subs == $md) ? ' (off) ' : null));
}
$s += 1;
}
} else {
$sht = 'No subtitles found in ' . $sub_dir;
}
$ht = '';
$ht .= '
';
$ht .= '
';
$ht .= '
';
$ht .= '';
$ht .= '';
$ht .= '
';
$ht .= VGenerate::headingArticle($language["backend.files.text.subtitles"] . $title, 'icon-paragraph-justify');
$ht .= '
';
$ht .= '
';
$ht .= '
';
$ht .= '
' . $language["frontend.global.saveupdate"] . ' ';
$ht .= VGenerate::simpleDivWrap('left-float', '', VGenerate::basicInput('button', 'save_changes', 'save-entry-button button-grey update-entry search-button form-button subs-trigger', '', 0, '
' . $language["frontend.global.saveupdate"] . ' ') . VGenerate::lb_Cancel(), 'display: inline-block-off;');
$ht .= '
';
$ht .= '
';
$ht .= ' ';
$ht .= ' ';
$ht .= '
';
$ht .= '
';
$html .= $ht;
/* save/update */
$_js .= '$(".subs-update").click(function(){';
$_js .= 'var file_key = $(this).attr("rel-key");';
$_js .= '$(".fancybox-wrap").mask("");';
$_js .= '$.post(current_url + menu_section + "?do=subs-update&type=' . $type . '&file_key="+file_key, $("#subs-form"+file_key).serialize(), function(data) {';
$_js .= '$("#subs-update-response"+file_key).html(data);';
$_js .= '$(".fancybox-wrap").unmask();';
$_js .= '});';
$_js .= '});';
$_js .= '$(".subs-trigger").click(function(){$(".subs-update").trigger("click");});';
$_js .= '$(".subs-list.icheck-box input").each(function () {
var self = $(this);
self.iCheck({
checkboxClass: "icheckbox_square-blue",
radioClass: "iradio_square-blue",
increaseArea: "20%"
//insert: "
" + label_text + " "
});
});
';
/* close popup */
$js .= $_js;
$html .= VGenerate::declareJS('$(document).ready(function(){' . $js . '});');
return $html;
}
/* manage banners */
public function bannerManager($file_key)
{
global $db, $cfg, $language, $class_database, $class_filter, $smarty;
$type = $class_filter->clr_str($_GET["type"]);
$ad_ids = '50, 51, 52, 53, 54, 55';
$title = $class_database->singleFieldValue('db_' . $type . 'files', 'file_title', 'file_key', $file_key);
$ba_ads = $class_database->singleFieldValue('db_' . $type . 'files', 'banner_ads', 'file_key', $file_key);
$_ba = $ba_ads != '' ? unserialize($ba_ads) : null;
$ads = $db->execute(sprintf("SELECT `adv_id`, `adv_name`, `adv_group` FROM `db_advbanners` WHERE `adv_group` IN (%s) AND `adv_active`='1' ORDER BY `adv_group`;", $ad_ids));
if ($ads->fields["adv_id"]) {
while (!$ads->EOF) {
$adv_id = $ads->fields["adv_id"];
$grp_id = $ads->fields["adv_group"];
$adv_grp = $class_database->singleFieldValue('db_advgroups', 'adv_name', 'db_id', $grp_id);
$bht .= ' fields["adv_id"], $_ba)) ? ' checked="checked"' : null) . '>' . $ads->fields["adv_name"] . ' (' . $adv_grp . ') ';
$ads->MoveNext();
}
} else {
$bht = '' . $language["backend.menu.no.categ.file"] . '
';
}
$ht = '';
$ht .= '
';
$ht .= '
';
$ht .= '
';
$ht .= '';
$ht .= '';
$ht .= '
';
$ht .= VGenerate::headingArticle($language["backend.adv.banner.for"] . $title, 'icon-' . ($type == 'doc' ? 'file' : ($type == 'blog' ? 'pencil2' : $type)));
$ht .= '
';
$ht .= '
';
$ht .= '
';
$ht .= VGenerate::simpleDivWrap('left-float', '', VGenerate::basicInput('button', 'save_changes', 'save-entry-button button-grey update-entry search-button form-button trg-update', '', $file_key, '
' . $language["frontend.global.saveupdate"] . ' ') . VGenerate::lb_Cancel(), 'display: inline-block-off;');
$ht .= '
Save/Update ';
$ht .= '
';
$ht .= '
';
$ht .= ' ';
$ht .= ' ';
$ht .= '
';
$ht .= '
';
$html .= $ht;
/* save/update */
$_js .= '$(".trg-update").click(function(){';
$_js .= '$(".banner-update").trigger("click");';
$_js .= '});';
$_js .= '$(".banner-update").click(function(){';
$_js .= 'var file_key = $(this).attr("rel-key");';
$_js .= '$(".fancybox-wrap").mask("");';
$_js .= '$.post(current_url + menu_section + "?do=banner-update&type=' . $type . '&file_key="+file_key, $("#banner-form"+file_key).serialize(), function(data) {';
$_js .= '$("#banner-update-response"+file_key).html(data);';
$_js .= '$(".fancybox-wrap").unmask();';
$_js .= '});';
$_js .= '});';
$_js .= '$(".banner-sel.icheck-box input").each(function () {
var self = $(this);
self.iCheck({
checkboxClass: "icheckbox_square-blue",
radioClass: "iradio_square-blue",
increaseArea: "20%"
//insert: "
" + label_text + " "
}); });';
/* close popup */
$js .= $_js;
$html .= VGenerate::declareJS('$(document).ready(function(){' . $js . '});');
return $html;
}
/* manage fp ads */
public function FPadsManager($file_key)
{
global $db, $cfg, $language, $class_database, $class_filter, $smarty;
$s = 0;
$title = $class_database->singleFieldValue('db_videofiles', 'file_title', 'file_key', $file_key);
$fp_ads = $class_database->singleFieldValue('db_videofiles', 'fp_ads', 'file_key', $file_key);
$_fp = $fp_ads != '' ? unserialize($fp_ads) : null;
$type = $class_filter->clr_str($_GET["type"]);
$ads = $db->execute("SELECT `ad_id`, `ad_name`, `ad_cuepoint` FROM `db_fpadentries` WHERE `ad_active`='1';");
$html = '';
$html .= '
';
$html .= '
';
$html .= '
';
$html .= '';
$html .= '';
$html .= '
';
$html .= VGenerate::headingArticle($language["backend.adv.select.for." . $type] . $title, 'icon-video');
$html .= '
';
$html .= '
';
$html .= '
';
$html .= '
';
$html .= '
';
$html .= ' ';
$html .= ' ';
$html .= '
';
$html .= '
';
/* save/update */
$_js .= '$(".trg-update").click(function(){';
$_js .= '$(".ad-update").trigger("click");';
$_js .= '});';
$_js .= '$(".ad-update").click(function(){';
$_js .= 'var file_key = $(this).attr("rel-key");';
$_js .= '$(".fancybox-inner").mask(" ");';
$_js .= '$.post(current_url + menu_section + "?do=ad-update&type=' . $type . '&file_key="+file_key, $("#ad-form"+file_key).serialize(), function(data) {';
$_js .= '$("#ad-update-response"+file_key).html(data);';
$_js .= '$(".fancybox-inner").unmask();';
$_js .= '});';
$_js .= '});';
$_js .= '$("#ad-rolls.icheck-box input").each(function () {
var self = $(this);
self.iCheck({
checkboxClass: "icheckbox_square-blue",
radioClass: "iradio_square-blue",
increaseArea: "20%"
//insert: "
" + label_text + " "
}); });';
$js .= $_js;
$html .= VGenerate::declareJS('$(document).ready(function(){' . $js . '});');
return $html;
}
/* manage videojs ads */
public function VJSadsManager($file_key)
{
global $db, $cfg, $language, $class_database, $class_filter, $smarty;
$s = 0;
$type = $class_filter->clr_str($_GET["type"]);
$title = $class_database->singleFieldValue('db_' . $type . 'files', 'file_title', 'file_key', $file_key);
$jw_ads = $class_database->singleFieldValue('db_' . $type . 'files', 'vjs_ads', 'file_key', $file_key);
$_jw = $jw_ads != '' ? unserialize($jw_ads) : null;
$off = $db->execute("SELECT `ad_id`, `ad_name`, `ad_client` FROM `db_vjsadentries` WHERE `ad_active`='1';");
$ht = '';
$ht .= '
';
$ht .= '
';
$ht .= '
';
$ht .= '';
$ht .= '';
$ht .= '
';
$ht .= VGenerate::headingArticle($language["backend.adv.select.for." . $type] . $title, 'icon-video');
$ht .= '
';
$ht .= '
';
$ht .= '
';
$ht .= VGenerate::simpleDivWrap('left-float', '', VGenerate::basicInput('button', 'save_changes', 'save-entry-button button-grey update-entry search-button form-button trg-update', '', $file_key, '
' . $language["frontend.global.saveupdate"] . ' ') . VGenerate::lb_Cancel(), 'display: inline-block-off;');
$ht .= '
Save/Update ';
$ht .= '
';
$ht .= '
';
$ht .= ' ';
$ht .= ' ';
$ht .= '
';
$ht .= '
';
$html .= $ht;
/* save/update */
$_js .= '$(".trg-update").click(function(){';
$_js .= '$(".ad-update").trigger("click");';
$_js .= '});';
$_js .= '$(".ad-update").click(function(){';
$_js .= 'var file_key = $(this).attr("rel-key");';
$_js .= '$(".fancybox-inner").mask(" ");';
$_js .= '$.post(current_url + menu_section + "?do=ad-update&type=' . $type . '&file_key="+file_key, $("#ad-form"+file_key).serialize(), function(data) {';
$_js .= '$("#ad-update-response"+file_key).html(data);';
$_js .= '$(".fancybox-inner").unmask();';
$_js .= '});';
$_js .= '});';
$_js .= '$("#add-rolls.icheck-box input").each(function () {
var self = $(this);
self.iCheck({
checkboxClass: "icheckbox_square-blue",
radioClass: "iradio_square-blue",
increaseArea: "20%"
//insert: "
" + label_text + " "
}); });';
/* close popup */
$js .= $_js;
$html .= VGenerate::declareJS('$(document).ready(function(){' . $js . '});');
return $html;
}
/* manage jw ads */
public function JWadsManager($file_key)
{
global $db, $cfg, $language, $class_database, $class_filter, $smarty;
$s = 0;
$type = $class_filter->clr_str($_GET["type"]);
$title = $class_database->singleFieldValue('db_' . $type . 'files', 'file_title', 'file_key', $file_key);
$jw_ads = $class_database->singleFieldValue('db_' . $type . 'files', 'jw_ads', 'file_key', $file_key);
$_jw = $jw_ads != '' ? unserialize($jw_ads) : null;
$pre = $db->execute("SELECT `ad_id`, `ad_name`, `ad_client` FROM `db_jwadentries` WHERE `ad_position`='pre' AND `ad_active`='1';");
if ($pre->fields["ad_id"]) {
$preroll = '';
$preroll .= '--- ';
while (!$pre->EOF) {
$preroll .= 'fields["ad_id"], $_jw)) ? ' selected="selected"' : null) . '>' . $pre->fields["ad_name"] . ' (' . $pre->fields["ad_client"] . ') ';
$pre->MoveNext();
}
$preroll .= ' ';
}
$post = $db->execute("SELECT `ad_id`, `ad_name`, `ad_client` FROM `db_jwadentries` WHERE `ad_position`='post' AND `ad_active`='1';");
if ($post->fields["ad_id"]) {
$postroll = '';
$postroll .= '--- ';
while (!$post->EOF) {
$postroll .= 'fields["ad_id"], $_jw)) ? ' selected="selected"' : null) . '>' . $post->fields["ad_name"] . ' (' . $post->fields["ad_client"] . ') ';
$post->MoveNext();
}
$postroll .= ' ';
}
$off = $db->execute("SELECT `ad_id`, `ad_name`, `ad_client` FROM `db_jwadentries` WHERE `ad_position`='offset' AND `ad_active`='1';");
$ht = '';
$ht .= '
';
$ht .= '
';
$ht .= '
';
$ht .= '';
$ht .= '';
$ht .= '
';
$ht .= VGenerate::headingArticle($language["backend.adv.select.for." . $type] . $title, 'icon-video');
$ht .= '
';
$ht .= '
';
$ht .= '
';
$ht .= VGenerate::simpleDivWrap('left-float', '', VGenerate::basicInput('button', 'save_changes', 'save-entry-button button-grey update-entry search-button form-button trg-update', '', $file_key, '
' . $language["frontend.global.saveupdate"] . ' ') . VGenerate::lb_Cancel(), 'display: inline-block-off;');
$ht .= '
Save/Update ';
$ht .= '
';
$ht .= '
';
$ht .= ' ';
$ht .= ' ';
$ht .= '
';
$ht .= '
';
$html .= $ht;
/* save/update */
$_js .= '$(".trg-update").click(function(){';
$_js .= '$(".ad-update").trigger("click");';
$_js .= '});';
$_js .= '$(".ad-update").click(function(){';
$_js .= 'var file_key = $(this).attr("rel-key");';
$_js .= '$(".fancybox-inner").mask(" ");';
$_js .= '$.post(current_url + menu_section + "?do=ad-update&type=' . $type . '&file_key="+file_key, $("#ad-form"+file_key).serialize(), function(data) {';
$_js .= '$("#ad-update-response"+file_key).html(data);';
$_js .= '$(".fancybox-inner").unmask();';
$_js .= '});';
$_js .= '});';
$_js .= '$(function(){SelectList.init("ad_name_pre");});';
$_js .= '$(function(){SelectList.init("ad_name_post");});';
$_js .= '$("#mid-rolls.icheck-box input").each(function () {
var self = $(this);
self.iCheck({
checkboxClass: "icheckbox_square-blue",
radioClass: "iradio_square-blue",
increaseArea: "20%"
//insert: "
" + label_text + " "
}); });';
/* close popup */
$js .= $_js;
$html .= VGenerate::declareJS('$(document).ready(function(){' . $js . '});');
return $html;
}
/* update banner and video ads */
public function adUpdate($file_key, $banner = '')
{
global $db, $language, $cfg, $class_filter;
$type = $class_filter->clr_str($_GET["type"]);
if ($banner == '' and $cfg["video_player"] != 'vjs') {
$mid = array();
$pre = $class_filter->clr_str($_POST["ad_name_pre"]);
$post = $class_filter->clr_str($_POST["ad_name_post"]);
$mid = $_POST["ad_name_mid"];
$mid_ct = count($_POST["ad_name_mid"]);
$sar = $mid;
if ($cfg["video_player"] == 'jw') {
$sar[] = $pre;
$sar[] = $post;
}
} else {
$sar = $_POST["ad_name"];
}
$sar = serialize($sar);
$sct = ((md5($sar) === md5('a:2:{i:0;s:1:"0";i:1;s:1:"0";}')) or $sar === 'N;') ? 0 : ($mid_ct > 0 ? $mid_ct : count($sar));
$sql = sprintf("UPDATE `db_%sfiles` SET `%s`='%s' WHERE `file_key`='%s' LIMIT 1;", $type, ($banner == '' ? (($type == 'video' and $cfg["video_player"] == 'flow') ? 'fp' : ((($type == 'video' or $type == 'live' or $type == 'short') and $cfg["video_player"] == 'vjs') ? 'vjs' : $cfg[$type . "_player"])) . '_ads' : 'banner_ads'), ($sct == 0 ? null : $sar), $file_key);
$res = $db->execute($sql);
$ar = $db->Affected_Rows();
echo ($ar > 0 ? VGenerate::noticeTpl('', '', $language["notif.success.request"]) : null);
}
/* update video subtitles */
public function subsUpdate($file_key)
{
global $db, $language, $cfg, $class_database, $class_filter;
$type = $class_filter->clr_str($_GET["type"]);
$sar = ($cfg[$type . "_player"] == 'jw' or $cfg[$type . "_player"] == 'vjs') ? serialize($_POST["sub_name"]) : $class_filter->clr_str($_POST["sub_name"]);
$sct = $sar == 'N;' ? 0 : 1;
$dbt = $cfg[$type . "_player"] == 'vjs' ? 'vjs_subs' : ($cfg[$type . "_player"] == 'jw' ? 'jw_subs' : 'fp_subs');
if (($cfg[$type . "_player"] == 'jw' or $cfg[$type . "_player"] == 'vjs') and count($_POST["sub_name"]) > 0) {
$s = array();
foreach ($_POST["sub_name"] as $v) {
$label = $class_filter->clr_str($_POST["sub_label_" . $v]);
$default = $class_filter->clr_str($_POST["sub_default"]);
$s[$v] = array("label" => $label, "default" => ($default == $v ? 1 : 0));
}
$sar = serialize($s);
$sct = $sar == 'N;' ? 0 : 1;
}
$sql = sprintf("UPDATE `db_%ssubs` SET `%s`='%s' WHERE `file_key`='%s' LIMIT 1;", $type, $dbt, ($sct > 0 ? $sar : ""), $file_key);
$res = $db->execute($sql);
$ar = $db->Affected_Rows();
if (intval($ar) == 0 and $sct > 0) {
$class_database->doInsert('db_' . $type . 'subs', array("file_key" => $file_key, $dbt => $sar));
$ar = $db->Affected_Rows();
}
echo ($ar > 0 ? VGenerate::noticeTpl('', '', $language["notif.success.request"]) : null);
}
/* file details */
public function fileDetails($_dsp, $type, $entry_id, $info_array)
{
global $cfg, $language, $class_database, $db, $smarty;
$db_id = $info_array[0];
$_init = VbeEntries::entryInit($_dsp, $db_id, $entry_id);
$_date = date('D, m/d/Y, H:i:s A', strtotime($dc_date));
$_dsp = $_init[0];
$_user_key = $info_array[1];
$_title = $info_array[2];
$_descr = $info_array[3];
$_tags = $info_array[4];
$_ct_id = $info_array[5];
$_privacy = $info_array[6];
$_approved = $info_array[7];
$_deleted = $info_array[8];
$_active = $info_array[9];
$_db_id = $info_array[10];
$_file_name = $info_array[11];
$_file_size = $info_array[12];
$_file_dur = $info_array[13];
$_file_hd = $info_array[14];
$_file_mob = $info_array[15];
$_file_feat = $info_array[16];
$_file_views = $info_array[17];
$_file_fav = $info_array[18];
$_file_comm = $info_array[19];
$_file_resp = $info_array[20];
$_file_like = $info_array[21];
$_file_dis = $info_array[22];
$_file_date = $info_array[23];
$_file_flag = $info_array[24];
$_file_src = $info_array[25];
$_up_server = $info_array[26];
$_tmb_server = $info_array[27];
$_file_promo = $info_array[28];
$_old_key = $info_array[29];
$_has_pv = $info_array[30];
$_is_short = $info_array[31];
$thumb_cache = $info_array[32];
$gs = (($cfg["conversion_" . $type . "_previews"] == 1 and $_has_pv == 1 and $_old_key == 0) or ($cfg["conversion_" . $type . "_previews"] == 0 and $_old_key == 0)) ? md5($cfg["global_salt_key"] . $db_id) : $db_id;
$a_rel = 'rel="popuprel' . $db_id . '" rel-fkey="' . $db_id . '" rel-ukey="' . $_user_key . '" rel-hd="' . ($type[0] == 'b' ? 'b' : $_file_hd) . '" class="popup' . ($type[0] == 'i' ? ' fancy-img' : null) . '"';
$img_url = $type[0] == 'i' ? VGenerate::thumbSigned(array("type" => "image", "server" => "upload", "key" => '/' . $_user_key . '/i/' . $gs . '.jpg'), array($db_id, $gs), $_user_key, 0, 1) : null;
$img_url_pv = $type[0] == 'i' ? VGenerate::thumbSigned(array("type" => "image", "server" => "upload", "key" => '/' . $_user_key . '/i/' . $db_id . '.jpg'), array($db_id, $gs), $_user_key, 0, 1) : null;
$tmb_url = VGenerate::thumbSigned($type, $db_id, array($_user_key, $thumb_cache), 0, 1, 0);
if (file_exists($cfg["media_files_dir"] . '/' . $_user_key . '/t/' . $db_id . '/1' . $thumb_cache . '.jpg')) {
$_thumb = ' ' . (($cfg["conversion_" . $type . "_previews"] == 1 and $_has_pv == 1 and $_old_key == 0) ? $language["backend.files.menu.full"] : null) . ' ';
$_thumb_2 = ($cfg["conversion_" . $type . "_previews"] == 1 and $_has_pv == 1 and $_old_key == 0) ? ' ' . $language["backend.files.menu.preview"] . ' ' : null;
} else {
$_thumb = '' . VFileinfo::get_progress($db_id) . '
';
}
$_btn = VGenerate::simpleDivWrap('left-float', '', VGenerate::basicInput('button', 'save_changes', 'save-entry-button button-grey search-button form-button ' . ($_GET["do"] == 'add' ? 'new-entry' : 'update-entry'), '', $entry_id, '' . ($_GET["do"] == 'add' ? $language["frontend.global.savenew"] : $language["frontend.global.saveupdate"]) . ' '), 'display: inline-block-off;');
$tabs = '
';
$tabs .= '';
$tabs .= '
';
$tabs .= '
';
$tabs .= '
';
$tabs .= '
';
$tabs .= '
';
$tabs .= '
';
$tabs .= ($type[0] == 'b') ? '
' : null;
$tabs .= (($type[0] == 'v' or $type[0] == 'l') and $_file_src == 'local') ? '
' : null;
$tabs .= '
';
$tabs .= ($type[0] == 'v' and $_file_src == 'local') ? '
' : null;
$tabs .= (($_file_src == 'local' or ($type[0] != 'v' and $type[0] != 'l')) and $_up_server == 0) ? '
' : null;
$tabs .= (($_file_src == 'local' and ($type[0] != 'i' and $type[0] != 'b' and $type[0] != 'l')) and $_up_server == 0) ? '
' : null;
$tabs .= '
';
$html = '
';
$html .= '';
$html .= VGenerate::swiperjs('main', 'swiper-' . $db_id);
return $html;
}
/* server paths */
public function serverPaths()
{
global $cfg, $smarty, $class_filter, $class_database, $db;
$db_id = $class_filter->clr_str($_GET["file_key"]);
$type = $class_filter->clr_str($_GET["type"]);
$sql = sprintf("SELECT
A.`embed_src`, A.`file_title`, B.`usr_key`
FROM `db_%sfiles` A, `db_accountuser` B
WHERE
A.`usr_id`=B.`usr_id` AND
A.`file_key`='%s'
LIMIT 1;", $type, $db_id);
$rs = $db->execute($sql);
$_file_src = $rs->fields["embed_src"];
$_user_key = $rs->fields["usr_key"];
$_title = $rs->fields["file_title"];
$html = null;
if ($_file_src == 'local' or $type[0] != 'v') {
$html .= '';
$html .= '
';
$html .= '
';
$html .= '';
$html .= '';
$html .= '
';
$html .= VGenerate::headingArticle('Server paths: ' . $_title . ' ', 'icon-' . ($type == 'doc' ? 'file' : ($type == 'blog' ? 'pencil2' : $type)));
$html .= '
';
$html .= '
';
$ds = md5($cfg["global_salt_key"] . $db_id);
switch ($type[0]) {
case "v":
$_flv = $cfg["media_files_dir"] . '/' . $_user_key . '/' . $type[0] . '/' . $db_id . '.360p.flv';
$_mp4h = $cfg["media_files_dir"] . '/' . $_user_key . '/' . $type[0] . '/' . $db_id . '.mp4';
$_mp4m = $cfg["media_files_dir"] . '/' . $_user_key . '/' . $type[0] . '/' . $db_id . '.mob.mp4';
$_mp4mf = $cfg["media_files_dir"] . '/' . $_user_key . '/' . $type[0] . '/' . $ds . '.mob.mp4';
$_fsrc = $class_database->singleFieldValue('db_' . $type . 'files', 'file_name', 'file_key', $db_id);
$_src = $cfg["upload_files_dir"] . '/' . $_user_key . '/' . $type[0] . '/' . $_fsrc;
$_mp4_360p = $cfg["media_files_dir"] . '/' . $_user_key . '/' . $type[0] . '/' . $db_id . '.360p.mp4';
$_mp4_360pf = $cfg["media_files_dir"] . '/' . $_user_key . '/' . $type[0] . '/' . $ds . '.360p.mp4';
$_mp4_480p = $cfg["media_files_dir"] . '/' . $_user_key . '/' . $type[0] . '/' . $db_id . '.480p.mp4';
$_mp4_480pf = $cfg["media_files_dir"] . '/' . $_user_key . '/' . $type[0] . '/' . $ds . '.480p.mp4';
$_mp4_720p = $cfg["media_files_dir"] . '/' . $_user_key . '/' . $type[0] . '/' . $db_id . '.720p.mp4';
$_mp4_720pf = $cfg["media_files_dir"] . '/' . $_user_key . '/' . $type[0] . '/' . $ds . '.720p.mp4';
$_mp4_1080p = $cfg["media_files_dir"] . '/' . $_user_key . '/' . $type[0] . '/' . $db_id . '.1080p.mp4';
$_mp4_1080pf = $cfg["media_files_dir"] . '/' . $_user_key . '/' . $type[0] . '/' . $ds . '.1080p.mp4';
$_mp4_prv = $cfg["media_files_dir"] . '/' . $_user_key . '/' . $type[0] . '/' . md5($db_id . "_preview") . '.mp4';
$html .= file_exists($_flv) ? VGenerate::simpleDivWrap('row no-top-padding', '', VbeSettings::checkPath($_flv)) : null;
$html .= file_exists($_mp4h) ? VGenerate::simpleDivWrap('row', '', VbeSettings::checkPath($_mp4h)) : null;
$html .= file_exists($_mp4_360p) ? VGenerate::simpleDivWrap('row', '', VbeSettings::checkPath($_mp4_360p)) : null;
$html .= file_exists($_mp4_360pf) ? VGenerate::simpleDivWrap('row', '', VbeSettings::checkPath($_mp4_360pf)) : null;
$html .= file_exists($_mp4_480p) ? VGenerate::simpleDivWrap('row', '', VbeSettings::checkPath($_mp4_480p)) : null;
$html .= file_exists($_mp4_480pf) ? VGenerate::simpleDivWrap('row', '', VbeSettings::checkPath($_mp4_480pf)) : null;
$html .= file_exists($_mp4_720p) ? VGenerate::simpleDivWrap('row', '', VbeSettings::checkPath($_mp4_720p)) : null;
$html .= file_exists($_mp4_720pf) ? VGenerate::simpleDivWrap('row', '', VbeSettings::checkPath($_mp4_720pf)) : null;
$html .= file_exists($_mp4_1080p) ? VGenerate::simpleDivWrap('row', '', VbeSettings::checkPath($_mp4_1080p)) : null;
$html .= file_exists($_mp4_1080pf) ? VGenerate::simpleDivWrap('row', '', VbeSettings::checkPath($_mp4_1080pf)) : null;
$html .= file_exists($_mp4m) ? VGenerate::simpleDivWrap('row', '', VbeSettings::checkPath($_mp4m)) : null;
$html .= file_exists($_mp4mf) ? VGenerate::simpleDivWrap('row', '', VbeSettings::checkPath($_mp4mf)) : null;
$html .= file_exists($_mp4_prv) ? VGenerate::simpleDivWrap('row', '', VbeSettings::checkPath($_mp4_prv)) : null;
$html .= file_exists($_src) ? VGenerate::simpleDivWrap('row', '', VbeSettings::checkPath($_src)) : null;
break;
case "i":
$_jpg = $cfg["media_files_dir"] . '/' . $_user_key . '/' . $type[0] . '/' . $db_id . '.jpg';
$_jpgpf = $cfg["media_files_dir"] . '/' . $_user_key . '/' . $type[0] . '/' . $ds . '.jpg';
$_fsrc = $class_database->singleFieldValue('db_' . $type . 'files', 'file_name', 'file_key', $db_id);
$_src = $cfg["upload_files_dir"] . '/' . $_user_key . '/' . $type[0] . '/' . $_fsrc;
$html .= file_exists($_jpg) ? VGenerate::simpleDivWrap('row no-top-padding', '', VbeSettings::checkPath($_jpg)) : null;
$html .= file_exists($_jpgpf) ? VGenerate::simpleDivWrap('row no-top-padding', '', VbeSettings::checkPath($_jpgpf)) : null;
$html .= file_exists($_src) ? VGenerate::simpleDivWrap('row', '', VbeSettings::checkPath($_src)) : null;
break;
case "a":
$_mp3 = $cfg["media_files_dir"] . '/' . $_user_key . '/' . $type[0] . '/' . $db_id . '.mp3';
$_mp3pf = $cfg["media_files_dir"] . '/' . $_user_key . '/' . $type[0] . '/' . $ds . '.mp3';
$_mp4 = $cfg["media_files_dir"] . '/' . $_user_key . '/' . $type[0] . '/' . $db_id . '.mp4';
$_mp4pf = $cfg["media_files_dir"] . '/' . $_user_key . '/' . $type[0] . '/' . $ds . '.mp4';
$_fsrc = $class_database->singleFieldValue('db_' . $type . 'files', 'file_name', 'file_key', $db_id);
$_src = $cfg["upload_files_dir"] . '/' . $_user_key . '/' . $type[0] . '/' . $_fsrc;
$html .= file_exists($_mp3) ? VGenerate::simpleDivWrap('row no-top-padding', '', VbeSettings::checkPath($_mp3)) : null;
$html .= file_exists($_mp3pf) ? VGenerate::simpleDivWrap('row no-top-padding', '', VbeSettings::checkPath($_mp3pf)) : null;
$html .= file_exists($_mp4) ? VGenerate::simpleDivWrap('row no-top-padding', '', VbeSettings::checkPath($_mp4)) : null;
$html .= file_exists($_mp4pf) ? VGenerate::simpleDivWrap('row no-top-padding', '', VbeSettings::checkPath($_mp4pf)) : null;
$html .= file_exists($_src) ? VGenerate::simpleDivWrap('row', '', VbeSettings::checkPath($_src)) : null;
break;
case "b":
$_tplb = $cfg["media_files_dir"] . '/' . $_user_key . '/' . $type[0] . '/' . $db_id . '.tplb';
$_fsrc = $class_database->singleFieldValue('db_' . $type . 'files', 'file_name', 'file_key', $db_id);
$_src = $cfg["upload_files_dir"] . '/' . $_user_key . '/' . $type[0] . '/' . $_fsrc;
$html .= file_exists($_tplb) ? VGenerate::simpleDivWrap('row no-top-padding', '', VbeSettings::checkPath($_tplb)) : null;
$html .= file_exists($_src) ? VGenerate::simpleDivWrap('row', '', VbeSettings::checkPath($_src)) : null;
break;
case "d":
$_pdf = $cfg["media_files_dir"] . '/' . $_user_key . '/' . $type[0] . '/' . $db_id . '.pdf';
$_pdfpf = $cfg["media_files_dir"] . '/' . $_user_key . '/' . $type[0] . '/' . $ds . '.pdf';
$_swf = $cfg["media_files_dir"] . '/' . $_user_key . '/' . $type[0] . '/' . $db_id . '.swf';
$_fsrc = $class_database->singleFieldValue('db_' . $type . 'files', 'file_name', 'file_key', $db_id);
$_src = $cfg["upload_files_dir"] . '/' . $_user_key . '/' . $type[0] . '/' . $_fsrc;
$html .= file_exists($_pdf) ? VGenerate::simpleDivWrap('row no-top-padding', '', VbeSettings::checkPath($_pdf)) : null;
$html .= file_exists($_pdfpf) ? VGenerate::simpleDivWrap('row no-top-padding', '', VbeSettings::checkPath($_pdfpf)) : null;
$html .= file_exists($_swf) ? VGenerate::simpleDivWrap('row', '', VbeSettings::checkPath($_swf)) : null;
$html .= file_exists($_src) ? VGenerate::simpleDivWrap('row', '', VbeSettings::checkPath($_src)) : null;
break;
}
$html .= '
';
$html .= '
';
$html .= ' ';
$html .= ' ';
$html .= '
';
$html .= '
';
}
return $html;
}
/* reset thumbnails */
public function thumbReset($video_id, $preview_reset = false)
{
include_once 'f_core/f_classes/class.conversion.php';
global $class_database, $cfg;
$user_id = $class_database->singleFieldValue('db_videofiles', 'usr_id', 'file_key', $video_id);
if ($user_id) {
$type = 'video';
} else {
$user_id = $class_database->singleFieldValue('db_shortfiles', 'usr_id', 'file_key', $video_id);
if ($user_id) {
$type = 'short';
}
}
$user_key = $class_database->singleFieldValue('db_accountuser', 'usr_key', 'usr_id', $user_id);
if ($user_id == '' or $user_key == '') {
return;
}
$vid = md5($cfg["global_salt_key"] . $video_id);
$cmd = sprintf("%s %s %s %s %s", $cfg["server_path_php"], $cfg["modules_dir_be"] . '/files_tmb.php', $video_id, $user_key, ($preview_reset ? 2 : 0));
exec($cmd . ' 2>&1', $output);
}
public function conversionLog()
{
global $cfg, $class_filter, $smarty;
$type = $class_filter->clr_str($_GET["type"]);
$file_key = $class_filter->clr_str($_GET["file_key"]);
$log_path = $cfg["logging_dir"] . '/log_conv/*/.' . $type . '_' . $file_key . '.log';
$html = '';
$html .= '
';
$html .= '
';
$html .= '';
$html .= '';
$html .= '
';
$html .= '' . $log_path . ' ';
$html .= ' ';
$html .= ' ';
$html .= '
';
$html .= '
';
foreach (glob($log_path) as $filename) {
if (file_exists($filename)) {
$html .= "$filename size " . filesize($filename) . " ";
}
}
if (file_exists($filename)) {
$html .= nl2br(file_get_contents($filename));
} else {
$html .= '.' . $type . '_' . $file_key . '.log not found';
}
$html .= '
';
$html .= '
';
$html .= ' ';
$html .= ' ';
$html .= '
';
$html .= '
';
$html .= '';
return $html;
}
/* list menu actions, sort files */
public function listMenuActions($type)
{
global $cfg, $language, $section, $href, $class_filter, $class_database;
$btn_id = 'sort-file-time';
$div_id = 'file-sort-div';
$type = 'file-time-actions';
$menu_arr = array(
"sort-live" => "files.menu.live",
"sort-active" => "files.menu.active",
"sort-inactive" => "files.menu.inactive",
"sort-approved" => "files.menu.approved",
"sort-pending" => "files.menu.pending",
"sort-flagged" => "files.menu.flagged",
"sort-personal" => "playlist.menu.personal",
"sort-private" => "playlist.menu.private",
"sort-public" => "playlist.menu.public",
"sort-longest" => "files.menu.longest",
"sort-shortest" => "files.menu.shortest",
"sort-recent" => "files.menu.recent",
"sort-promoted" => "files.menu.promoted",
"sort-nocateg" => "files.menu.nocateg",
"sort-featured" => "files.menu.featured",
"sort-views" => "files.menu.viewed",
"sort-comm" => "files.menu.commented",
"sort-resp" => "files.menu.responded",
"sort-liked" => "files.menu.most.liked",
"sort-disliked" => "files.menu.most.disliked",
"sort-fav" => "files.menu.favorited",
"sort-deleted" => "files.menu.deleted",
);
$menu_arr_icons = array(
"sort-live" => "icon-live",
"sort-active" => "icon-play",
"sort-inactive" => "icon-stop",
"sort-approved" => "icon-check",
"sort-pending" => "icon-pause",
"sort-flagged" => "icon-flag",
"sort-personal" => "icon-lock",
"sort-private" => "icon-key",
"sort-public" => "icon-globe",
"sort-longest" => "icon-stopwatch",
"sort-shortest" => "icon-stopwatch",
"sort-recent" => "icon-history",
"sort-promoted" => "icon-bullhorn",
"sort-nocateg" => "icon-list2",
"sort-featured" => "icon-star",
"sort-views" => "icon-eye",
"sort-comm" => "icon-comment",
"sort-resp" => "icon-comments",
"sort-liked" => "icon-thumbs-up",
"sort-disliked" => "icon-thumbs-down",
"sort-fav" => "icon-heart",
"sort-deleted" => "icon-times",
);
$state_arr = array(
"sort-live" => "files.menu.live",
"sort-active" => "files.menu.active",
"sort-inactive" => "files.menu.inactive",
"sort-approved" => "files.menu.approved",
"sort-pending" => "files.menu.pending",
"sort-promoted" => "files.menu.promoted",
"sort-featured" => "files.menu.featured",
"sort-flagged" => "files.menu.flagged",
"sort-public" => "playlist.menu.public",
"sort-private" => "playlist.menu.private",
"sort-personal" => "playlist.menu.personal",
"sort-nocateg" => "files.menu.nocateg",
"sort-deleted" => "files.menu.deleted",
);
$state_arr_icons = array(
"sort-live" => "icon-live",
"sort-active" => "icon-play",
"sort-inactive" => "icon-stop",
"sort-approved" => "icon-check",
"sort-pending" => "icon-pause",
"sort-flagged" => "icon-flag",
"sort-personal" => "icon-lock",
"sort-private" => "icon-key",
"sort-public" => "icon-globe",
"sort-promoted" => "icon-bullhorn",
"sort-featured" => "icon-star",
"sort-nocateg" => "icon-list2",
"sort-deleted" => "icon-times",
);
$stats_arr = array(
"sort-recent" => "files.menu.recent",
"sort-views" => "files.menu.viewed",
"sort-comm" => "files.menu.commented",
"sort-resp" => "files.menu.responded",
"sort-liked" => "files.menu.most.liked",
"sort-disliked" => "files.menu.most.disliked",
"sort-fav" => "files.menu.favorited",
);
$stats_arr_icons = array(
"sort-recent" => "icon-clock",
"sort-views" => "icon-eye",
"sort-comm" => "icon-comment",
"sort-resp" => "icon-comments",
"sort-liked" => "icon-thumbs-up",
"sort-disliked" => "icon-thumbs-up2",
"sort-fav" => "icon-heart",
);
$length_arr = array(
"sort-longest" => "files.menu.longest",
"sort-shortest" => "files.menu.shortest",
);
$length_arr_icons = array(
"sort-longest" => "icon-stopwatch",
"sort-shortest" => "icon-stopwatch",
);
if ($_GET["s"] != 'backend-menu-entry6-sub6') {
unset($menu_arr["sort-live"]);
unset($menu_arr_icons["sort-live"]);
unset($state_arr["sort-live"]);
unset($state_arr_icons["sort-live"]);
}
if ($_GET["s"] == 'backend-menu-entry6-sub2' or $_GET["s"] == 'backend-menu-entry6-sub7' or $_GET["s"] == 'backend-menu-entry6-sub4' or $_GET["s"] == 'backend-menu-entry6-sub5') {
unset($menu_arr["sort-longest"]);
unset($menu_arr["sort-shortest"]);
}
$int_val = $_POST[str_replace('-', '_', $div_id) . '_val'] == '' ? (($_GET["do"] != '' and array_key_exists($_GET["do"], $menu_arr)) ? $_GET["do"] : 'sort-recent') : $_POST[str_replace('-', '_', $div_id) . '_val'];
$menu_top = ($_GET["do"] == '' or $language[$menu_arr[$int_val]] == '') ? $language["files.menu.recent"] : $language[$menu_arr[$int_val]];
unset($menu_arr[$int_val]);
if (substr($_GET["s"], 0, 20) == 'backend-menu-entry11') {
//browse by category
$s_arr = explode("-", $class_filter->clr_str($_GET["s"]));
$s_t = substr($s_arr[3], 3);
}
$m_count = count($menu_arr);
$html .= '';
$html .= '
';
$html .= VGenerate::declareJS('$(function() { $( "#' . $type . '" ).dlmenu({ animationClasses : { classin : "dl-animate-in-5", classout : "dl-animate-out-5" } }); });');
return $html;
}
/* sub menus */
public function listMenuActions_subMenu($menu_arr, $icon_arr)
{
global $language;
$div_id = 'file-sort-div';
$html .= '';
return $html;
}
/* list menu actions, file types */
public function listTypeActions($type)
{
global $cfg, $language, $section, $href, $class_filter, $class_database, $db;
$btn_id = 'sort-file-type';
$div_id = 'file-type-div';
$type = 'file-type-actions';
if (substr($_GET["s"], 0, 20) == 'backend-menu-entry11') {
//browse by category
$s_arr = explode("-", $class_filter->clr_str($_GET["s"]));
$s_t = substr($s_arr[3], 3);
}
if ($_GET["s"] == 'backend-menu-entry6-sub1' or $s_t[0] == 'v') {
$menu_arr = array(
"sort-all" => "backend.files.menu.all",
"sort-flv" => "backend.files.menu.flv",
"sort-mp4" => "backend.files.menu.mp4",
);
$menu_arr_icons = array(
"sort-all" => "icon-list",
"sort-flv" => "icon-laptop",
"sort-mp4" => "icon-screen",
);
$rs = $db->execute(sprintf("SELECT `db_id`, `embed_src` FROM `db_videofiles` WHERE `embed_src`!='local' GROUP BY `embed_src`;"));
if ($rs->fields["db_id"]) {
while (!$rs->EOF) {
$embed_src = $rs->fields["embed_src"];
$menu_arr["sort-" . $embed_src] = ucfirst($embed_src);
$menu_arr_icons["sort-" . $embed_src] = 'icon-code';
$rs->MoveNext();
}
}
} elseif ($_GET["s"] == 'backend-menu-entry6-sub7' or $s_t[0] == 's') {
$menu_arr = array(
"sort-all" => "backend.files.menu.all",
"sort-mp4" => "backend.files.menu.mp4",
);
$menu_arr_icons = array(
"sort-all" => "icon-list",
"sort-mp4" => "icon-screen",
);
$rs = $db->execute(sprintf("SELECT `db_id`, `embed_src` FROM `db_shortfiles` WHERE `embed_src`!='local' GROUP BY `embed_src`;"));
if ($rs->fields["db_id"]) {
while (!$rs->EOF) {
$embed_src = $rs->fields["embed_src"];
$menu_arr["sort-" . $embed_src] = ucfirst($embed_src);
$menu_arr_icons["sort-" . $embed_src] = 'icon-code';
$rs->MoveNext();
}
}
} elseif ($_GET["s"] == 'backend-menu-entry6-sub4' or $s_t[0] == 'd') {
$menu_arr = array(
"sort-all" => "backend.files.menu.all",
"sort-pdf" => "backend.files.menu.pdf",
);
$menu_arr_icons = array(
"sort-all" => "icon-list",
"sort-pdf" => "icon-file-pdf",
);
}
$int_val = $_POST[str_replace('-', '_', $div_id) . '_val'] == '' ? (($_GET["for"] != '' and array_key_exists($_GET["for"], $menu_arr)) ? $_GET["for"] : 'sort-all') : $_POST[str_replace('-', '_', $div_id) . '_val'];
$menu_top = ($_GET["for"] == '' or $language[$menu_arr[$int_val]] == '') ? $language["backend.files.menu.all"] : $language[$menu_arr[$int_val]];
unset($menu_arr[$int_val]);
if (!is_array($menu_arr)) {
$menu_arr = array();
}
$m_count = count($menu_arr);
$html .= '';
$html .= '
';
$html .= VGenerate::declareJS('$(function() { $( "#' . $type . '" ).dlmenu({ animationClasses : { classin : "dl-animate-in-5", classout : "dl-animate-out-5" } }); });');
return $html;
}
/* count files */
public function fileCount($type)
{
global $db, $class_filter, $class_database;
if (isset($_GET["k"])) {
return 1;
}
$_u = $_GET["u"] != '' ? sprintf("WHERE `usr_id`='%s'", $class_database->singleFieldValue('db_accountuser', 'usr_id', 'usr_key', $class_filter->clr_str(substr($_GET["u"], 1)))) : null;
$rs = $db->execute(sprintf("SELECT COUNT(*) AS `total` FROM `db_%sfiles` %s;", $type, $_u));
return $rs->fields["total"];
}
/* count all files (discontinued) */
public function fileCountAll()
{
return;
global $db, $class_filter, $class_database;
$_u = $_GET["u"] != '' ? sprintf(" WHERE `usr_id`='%s'", $class_database->singleFieldValue('db_accountuser', 'usr_id', 'usr_key', $class_filter->clr_str(substr($_GET["u"], 1)))) : null;
$sql = sprintf("SELECT
( SELECT COUNT( * ) FROM `db_videofiles`%s) AS v_total,
( SELECT COUNT( * ) FROM `db_imagefiles`%s) AS i_total,
( SELECT COUNT( * ) FROM `db_audiofiles`%s) AS a_total,
( SELECT COUNT( * ) FROM `db_docfiles`%s) AS d_total;", $_u, $_u, $_u, $_u);
$res = $db->execute($sql);
$js = '$("#backend-menu-entry6-sub1-count").html("' . $res->fields["v_total"] . '");';
$js .= '$("#backend-menu-entry6-sub2-count").html("' . $res->fields["i_total"] . '");';
$js .= '$("#backend-menu-entry6-sub3-count").html("' . $res->fields["a_total"] . '");';
$js .= '$("#backend-menu-entry6-sub4-count").html("' . $res->fields["d_total"] . '");';
echo VGenerate::declareJS($js);
}
/* checkbox selection query */
public function cbSQL()
{
$db_arr = array();
foreach ($_POST["current_entry_id"] as $k => $v) {
$db_arr[] = sprintf("'%s'", $v);
}
return $db_q = sprintf("`file_key` IN (%s)", implode(', ', $db_arr));
}
/* email subscribers after approving files */
public function subscriptionMailer()
{
global $language, $cfg, $smarty;
$html = '';
$html .= '
';
$html .= VGenerate::simpleDivWrap('row', 'approve-update', '');
$html .= '
';
$html .= '';
$html .= '';
$html .= '
';
$html .= VGenerate::headingArticle($language["backend.files.text.approve.s0"], 'icon-check');
$html .= '
';
$html .= '
';
$html .= '';
$html .= '
';
$html .= ' ';
$html .= ' ';
$html .= '
';
$html .= '
';
/* close popup */
$js = '$("#usr-approve-form .icheck-box input").each(function () {
var self = $(this);
self.iCheck({
checkboxClass: "icheckbox_square-blue",
radioClass: "iradio_square-blue",
increaseArea: "20%"
//insert: "
" + label_text + " "
}); });
';
$html .= VGenerate::declareJS('$(document).ready(function(){' . $js . '});');
return $html;
}
/* confirm sending notification email after approving */
public function confirmApprove()
{
global $class_filter, $db, $language;
switch ($_GET["s"]) {
case "backend-menu-entry6-sub1":$type = 'video';
break;
case "backend-menu-entry6-sub2":$type = 'image';
break;
case "backend-menu-entry6-sub3":$type = 'audio';
break;
case "backend-menu-entry6-sub4":$type = 'doc';
break;
case "backend-menu-entry6-sub5":$type = 'blog';
break;
case "backend-menu-entry6-sub6":$type = 'live';
break;
case "backend-menu-entry6-sub7":$type = 'short';
break;
}
$notif = intval($_POST["notify_subscribers"]);
$cb = rawurldecode($class_filter->clr_str($_POST["cb_in2"]));
if ($notif == 1) {
$sql = sprintf("SELECT `usr_id`, `file_key` FROM `db_%sfiles` WHERE %s;", $type, $cb);
$res = $db->execute($sql);
if ($res->fields["usr_id"]) {
while (!$res->EOF) {
$do_notif = VUpload::notifySubscribers($res->fields["usr_id"], $type, $res->fields["file_key"], 1);
$res->MoveNext();
}
}
}
echo $_POST["notify_subscribers"] != '' ? VGenerate::noticeTpl('', '', $language["notif.success.request"]) : null;
}
/* delete files */
public function fileDelete($p)
{
global $cfg, $db, $class_filter, $class_database, $language;
$db_tbl = $p[0];
$sel_count = $p[1];
if ($cfg["paid_memberships"] == 1 and ($cfg["file_delete_method"] == 2 or $cfg["file_delete_method"] == 4)) {
$sql_sub = sprintf("SELECT `file_size` FROM `db_%sfiles` WHERE (##KEYS##)", $db_tbl);
}
switch ($cfg["file_delete_method"]) {
case "1":
case "2":
$sql = sprintf("UPDATE `db_%sfiles` SET `deleted`='1' WHERE (##KEYS##)", $db_tbl);
break;
case "3":
case "4":
$sql = sprintf("DELETE `files` FROM `db_%sfiles` AS `files` WHERE (##KEYS##)", $db_tbl);
break;
}
if ($sel_count > 0) {
$s = 0;
$db_whr_field = 'file_key';
$dbf = ($cfg["file_delete_method"] == 1 or $cfg["file_delete_method"] == 2) ? null : "`files`.";
for ($i = 0; $i < $sel_count; $i++) {
$_key = $class_filter->clr_str($_POST["current_entry_id"][$i]);
$usr_id = $class_database->singleFieldValue('db_' . $db_tbl . 'files', 'usr_id', 'file_key', $_key);
$usr_key = $class_database->singleFieldValue('db_accountuser', 'usr_key', 'usr_id', $usr_id);
$del_arr = array($_key);
$q = $dbf . "`" . $db_whr_field . "` = '" . $_key . "'";
$q1 = $cfg["paid_memberships"] == 1 ? "(" . $dbf . "`" . $db_whr_field . "` = '" . $_key . "' AND `is_subscription`='1')" : null;
$wh_sql = $q;
$f_sql = str_replace("##KEYS##", $wh_sql, $sql);
/* delete from subscription used space */
if ($cfg["paid_memberships"] == 1 and ($cfg["file_delete_method"] == 2 or $cfg["file_delete_method"] == 3 or $cfg["file_delete_method"] == 4)) {
$wh_sql1 = $q1;
$f_sql_sub = str_replace('`files`.', '', str_replace("##KEYS##", $wh_sql1, $sql_sub));
$rsub = $db->execute($f_sql_sub);
if ($rsub) {
while (!$rsub->EOF) {
$db->execute("UPDATE `db_packusers` SET `pk_usedspace`=`pk_usedspace`-" . $rsub->fields["file_size"] . ", `pk_total_" . $db_tbl . "`=`pk_total_" . $db_tbl . "`-1 WHERE `usr_id`='" . $usr_id . "' LIMIT 1;");
@$rsub->MoveNext();
}
}
}
//delete from activity
$del_act = $db->execute("DELETE FROM `db_useractivity` WHERE `act_type` LIKE '%" . $_key . "%';");
//delete from server and file owner favorites,playlists,history,liked,watchlist
$del_fav = VFiles::clearFavPl($del_arr, $db_tbl, $usr_id, $usr_key);
$do_action = $db->execute($f_sql);
if ($db->Affected_Rows() > 0) {
$s = $s + 1;
}
//delete from other user's entries
$del_other = VFiles::fileDeleteOther($db_tbl, $_key, array(0 => "favorites", 1 => "fav_list"));
$del_other = VFiles::fileDeleteOther($db_tbl, $_key, array(0 => "history", 1 => "history_list"));
$del_other = VFiles::fileDeleteOther($db_tbl, $_key, array(0 => "liked", 1 => "liked_list"));
$del_other = VFiles::fileDeleteOther($db_tbl, $_key, array(0 => "watchlist", 1 => "watch_list"));
}
if ($s > 0) {
echo VGenerate::noticeTpl('', '', $language["notif.success.request"]);
}
}
}
/* load blog contents */
public static function blog_loadContent()
{
global $language, $cfg, $class_filter, $db;
$file_key = $class_filter->clr_str($_GET["f"]);
$usr_key = $class_filter->clr_str($_GET["u"]);
$blog_tpl = $cfg["media_files_dir"] . '/' . $usr_key . '/b/' . $file_key . '.tplb';
if (file_exists($blog_tpl)) {
$html = '' . $file_key . ' ';
$html .= '' . file_get_contents($blog_tpl) . '
';
$html .= '';
$html .= '';
echo $html;
}
}
/* insert media into blogs */
public static function blog_insertMedia()
{
global $language, $cfg, $class_filter, $db, $smarty;
$type = $class_filter->clr_str($_GET["t"]);
$js = "$.fancybox.close(); if (typeof($('.blog-media-select li.thumb-selected').html()) != 'undefined') { tinymce.activeEditor.insertContent('[media_" . $type . "_'+$('.blog-media-select li.thumb-selected').attr('rel-key')+']'); }";
$html = '
' . str_replace('##TYPE##', $language["frontend.global." . $type[0]], $language["files.text.insert.url.type"]) . '
';
$ht_js = '(function() {[].slice.call(document.querySelectorAll(".tabs.pltabs")).forEach(function (el) {new CBPFWTabs(el);});})();';
$ht_js .= '
$(".find-url").on("click", function() {
url = current_url + "' . VHref::getKey('be_files') . '" + "?be=1&b=' . $bkey . '&do=find&t=' . $type . '";
$(".fancybox-inner").mask(" ");
$.post(url, $(".entry-form-class").serialize(), function(data) {
$("#find-url-response").html(data);
$(".fancybox-inner").unmask();
});
});
$( "#bulletin-file" ).on( "keydown", function(event) {
if(event.which == 13) {
event.preventDefault();
$(".find-url").click();
}
});
';
$html .= VGenerate::declareJS('$(document).ready(function(){' . $ht_js . '});');
echo $html;
}
/* lists of files to insert into blogs */
private static function blog_mediaList($type = false, $favorites = false)
{
global $language, $cfg, $class_filter, $db;
$html = null;
$uid = 0;
$for = !$type ? $class_filter->clr_str($_GET["t"]) : $type;
$sql = sprintf("SELECT
A.`thumb_server`, A.`thumb_cache`, A.`file_key`, A.`file_title`, D.`usr_key`
FROM
`db_%sfiles` A, `db_accountuser` D
WHERE
A.`usr_id`=D.`usr_id` AND
A.`privacy`!='personal' AND
A.`active`='1' AND
A.`approved`='1' AND
A.`deleted`='0' AND
A.`usr_id`>'0'
%s
GROUP BY A.`file_key`;", $for, $q);
$rs = $db->execute($sql);
if ($rs->fields["file_key"]) {
$s = 1;
$html .= '';
while (!$rs->EOF) {
$title = $rs->fields["file_title"];
$file_key = $rs->fields["file_key"];
$usr_key = $rs->fields["usr_key"];
$thumb_server = $rs->fields["thumb_server"];
$thumb_cache = $rs->fields["thumb_cache"];
$thumb_cache = $thumb_cache > 1 ? $thumb_cache : null;
$img_src = self::thumbnail(array($usr_key, $thumb_cache), $file_key, $thumb_server);
$thumbnail = ' ';
$html .= '' . $thumbnail . ' ';
$rs->MoveNext();
$s += 1;
}
$html .= ' ';
} else {
$html .= '' . $language["frontend.global.results.none"] . '
';
}
return $html;
}
/* search by url for inserting into blogs */
public static function blog_findMedia()
{
global $language, $cfg, $class_filter, $class_database, $db;
$type = $class_filter->clr_str($_GET["t"]);
$main_len = strlen($cfg["main_url"]);
/* checking file url */
$ch_file_url = $class_filter->clr_str($_POST["bulletin_file"]);
if (substr($ch_file_url, 0, $main_len) == $cfg["main_url"]) {
$url_arr = parse_url($ch_file_url);
if ($cfg["file_seo_url"] == 1) {
$a = explode("/", $url_arr["path"]);
$b = count($a);
$file_key = $a[$b - 2];
$tbl = $a[$b - 3];
$new_key = $tbl . "=" . $file_key;
} else {
$new_key = substr($url_arr["query"], 0, 18);
$new_info = explode("=", $new_key);
$tbl = $new_info[0];
$file_key = $new_info[1];
}
switch ($tbl) {
case "l":$db_tbl = 'live';
break;
case "v":$db_tbl = 'video';
break;
case "s":$db_tbl = 'short';
break;
case "i":$db_tbl = 'image';
break;
case "a":$db_tbl = 'audio';
break;
case "d":$db_tbl = 'doc';
break;
case "b":$db_tbl = 'blog-off';
break;
}
$m = $tbl == 'd' ? 'document' : $db_tbl;
if ($db_tbl != $type) {
echo '' . $language["frontend.global.results.none"] . '
';
exit;
}
$_uid = $class_database->singleFieldValue('db_' . $db_tbl . 'files', 'usr_id', 'file_key', $file_key);
$_sql = sprintf("SELECT
B.`usr_key`,
C.`thumb_server`, C.`thumb_server`,
C.`file_title`
FROM
`db_accountuser` B, `db_%sfiles` C
WHERE
C.`usr_id`=B.`usr_id` AND
C.`file_key`='%s' AND
C.`privacy`%s AND
C.`approved`='1' AND
C.`deleted`='0' AND
C.`active`='1'
LIMIT 1;", $db_tbl, $file_key, ($_uid == $_SESSION["USER_ID"] ? "!='personal'" : "='public'"));
$dbc = $db->execute($_sql);
if ($cfg[$m . "_module"] == 1 and $_uid > 0 and $dbc->fields["usr_id"] == $_uid) {
$usr_key = $dbc->fields["usr_key"];
$thumb_server = $dbc->fields["thumb_server"];
$title = $dbc->fields["file_title"];
$thumb_cache = $dbc->fields["thumb_cache"];
$thumb_cache = $thumb_cache > 1 ? $thumb_cache : null;
$img_src = self::thumbnail(array($usr_key, $thumb_cache), $file_key, $thumb_server);
$thumbnail = ' ';
$js = "$.fancybox.close(); if (typeof($('#find-url-response .vs-column').html()) != 'undefined') { tinymce.activeEditor.insertContent('[media_" . $db_tbl . "_" . $file_key . "]'); }";
echo $html = '
' . $thumbnail . '
' . $title . '
' . $language["files.text.insert.add.to"] . '
';
} else {
echo '' . $language["frontend.global.results.none"] . '
';
}
} else {
echo '' . $language["frontend.global.results.none"] . '
';
}
}
/* adding new blog */
public static function newBlog()
{
global $language, $cfg, $class_filter, $class_database, $db;
$for = isset($_GET["t"]) ? $class_filter->clr_str($_GET["t"]) : 'blog';
$blog_response = isset($_GET["r"]) ? true : false;
if ($cfg[$for . "_module"] == 1) {
if ($_POST) {
$owner = $class_filter->clr_str($_POST["add_new_owner"]);
$ukey = $class_filter->clr_str($_POST["add_new_owner_key"]);
$title = $class_filter->clr_str($_POST["add_new_title"]);
$descr = $class_filter->clr_str($_POST["add_new_descr"]);
$tags = $class_filter->clr_str($_POST["add_new_tags"]);
$categ = (int) $_POST["file_category_0"];
$usr_id = (int) $class_database->singleFieldValue('db_accountuser', 'usr_id', 'usr_key', $ukey);
$_p = unserialize($class_database->singleFieldValue('db_accountuser', 'usr_perm', 'usr_id', $usr_id));
if (!isset($_p["perm_upload_s"])) {
$_p["perm_upload_s"] = 1;
}
$error = $_p["perm_upload_" . $for[0]] == '0' ? $language["notif.error.invalid.request"] : null;
$error = $error != '' ? $error : ($owner == '' ? $language["notif.error.required.field"] . $language["files.text.file.owner"] : ($title == '' ? $language["notif.error.required.field"] . $language["files.text.file.title"] : ($tags == '' ? $language["notif.error.required.field"] . $language["files.text.file.tags"] : ($categ == 0 ? $language["notif.error.required.field"] . $language["files.text.file.categ"] : false))));
if ($error) {
echo VGenerate::noticeTpl('', $error, '');
} else {
$db_tbl_info = 'db_' . $for . 'files';
$db_tbl_perm = 'db_' . $for . 'files';
$fileext = 'tplb';
$filekey = VUserinfo::generateRandomString(10);
$embedkey = VUserinfo::generateRandomString(10);
$usr_key = $ukey;
$db_approved = 1;
if ($usr_id == 0) {
echo VGenerate::noticeTpl('', $language["notif.error.invalid.request"], '');
exit;
}
$v_info = array(
"usr_id" => $usr_id,
"file_key" => $filekey,
"old_file_key" => 0,
"file_type" => $fileext,
"file_name" => null,
"file_size" => null,
"upload_date" => date("Y-m-d H:i:s"),
"is_subscription" => 0,
"file_views" => 0,
"file_comments" => 0,
"file_responses" => 0,
"file_like" => 0,
"file_dislike" => 0,
"embed_key" => $embedkey,
"file_title" => $title,
"file_description" => $descr,
"file_tags" => VForm::clearTag($tags),
"file_category" => $categ,
"approved" => $db_approved,
"privacy" => "public",
"comments" => "all",
"comment_votes" => 1,
"rating" => 1,
"responding" => "all",
"embedding" => 1,
"social" => 1,
);
$do_db = $class_database->doInsert($db_tbl_info, $v_info);
if ($db->Affected_Rows() > 0) {
/* file count */
$ct_update = $db->execute(sprintf("UPDATE `db_accountuser` SET `usr_%s_count`=`usr_%s_count`+1 WHERE `usr_id`='%s' LIMIT 1;", $for[0], $for[0], $usr_id));
/* activity */
$log = ($cfg["activity_logging"] == 1 and $action = new VActivity($usr_id, 0)) ? $action->addTo('log_upload', $for . ':' . $filekey) : null;
/* end if broadcast details */
if ($for == 'live') {
$_p = unserialize($class_database->singleFieldValue('db_accountuser', 'usr_perm', 'usr_id', $usr_id));
if ($_p["perm_upload_l"] == '1') {
$db->execute(sprintf("UPDATE `db_livefiles` SET `stream_key`='%s', `stream_key_active`='1', `stream_vod`='%s', `stream_chat`='%s', `file_duration`='1' WHERE `file_key`='%s' LIMIT 1;", md5($cfg["global_salt_key"] . $usr_id . SK_INC), $_p["perm_live_vod"], $_p["perm_live_chat"], $filekey));
}
$tmp_file = str_replace($cfg["main_url"], $cfg["main_dir"], VUseraccount::getProfileImage($usr_id, false));
if ($tmp_file && is_file($tmp_file)) {
$src_folder = $cfg["media_files_dir"] . '/' . $usr_key . '/t/' . $filekey . '/';
$conv = new VDocument();
$conv->log_setup($filekey, false);
if ($conv->createThumbs_ffmpeg($src_folder, '1', 320, 180, $filekey, $usr_key, $tmp_file)) {}
if ($conv->createThumbs_ffmpeg($src_folder, '0', 640, 360, $filekey, $usr_key, $tmp_file)) {}
}
$js = '$(document).ready(function(){ $("#add-new-blog-form input, #add-new-blog-form textarea").val(""); });';
echo VGenerate::declareJS($js);
echo VGenerate::noticeTpl('', '', $language["notif.success.request"]);
return;
}
/* copy blog file */
$blog_file = $cfg["ww_templates_dir"] . '/tpl_page/tpl_blog.tpl';
$blog_tmb = $cfg["global_images_dir"] . '/default-blog.png';
if (file_exists($blog_file)) {
$dst_file = $cfg["media_files_dir"] . '/' . $usr_key . '/b/' . $filekey . '.tplb';
$dst_dir = $cfg["media_files_dir"] . '/' . $usr_key . '/t/' . $filekey;
$dst_tmb = $dst_dir . '/1.jpg';
if (copy($blog_file, $dst_file)) {
if (mkdir($dst_dir, 0777)) {
copy($blog_tmb, $dst_tmb);
echo VGenerate::declareJS('$(".login-input").val("");');
echo VGenerate::noticeTpl('', '', $language["notif.success.request"]);
$notify = VUpload::notifySubscribers($usr_id, $for, $filekey, 1, $usr_key);
}
}
} else {
echo VGenerate::noticeTpl('', $language["notif.error.invalid.request"], '');
}
}
}
} else {
$c = VGenerate::simpleDivWrap('selector be', '', VFiles::fileCategorySelect('upload'));
$html = '
';
$html .= '
';
echo $html;
}
}
}
public static function blog_saveContent()
{
global $language, $cfg, $class_filter, $db;
$u = 0;
$usr_key = $class_filter->clr_str($_POST["u"]);
$file_key = $class_filter->clr_str($_POST["f"]);
$blog_tpl = $cfg["media_files_dir"] . '/' . $usr_key . '/b/' . $file_key . '.tplb';
$blog_html = urldecode($_POST["blog_html"]);
if (!file_exists($blog_tpl)) {
touch($blog_tpl);
}
if (file_exists($blog_tpl)) {
if (file_put_contents($blog_tpl, $blog_html)) {
echo VGenerate::noticeTpl('', '', $language["notif.success.request"]);
}
}
}
/* generate thumbnail url location */
private static function thumbnail($usr_key, $file_key, $thumb_server = 0)
{
global $language, $cfg, $class_filter, $db;
$type = $class_filter->clr_str($_GET["t"]);
$thumb_cache = null;
$new_key = $usr_key;
if (is_array($usr_key)) {
$thumb_cache = $usr_key[1];
$usr_key = $usr_key[0];
}
if ($thumb_server > 0) {
$expires = 0;
$custom_policy = 0;
$nr = 1;
return VGenerate::thumbSigned($type, $file_key, $new_key, $expires, $custom_policy, $nr);
}
return $cfg["media_files_url"] . '/' . $usr_key . '/t/' . $file_key . '/1' . $thumb_cache . '.jpg';
}
}