execute(sprintf("SELECT `usr_perm` FROM `db_accountuser` WHERE `usr_id`='%s' LIMIT 1;", $uid));
$perm = unserialize($p->fields['usr_perm']);
}
/* layout start */
$html = $side == 'frontend' ? '
' . VGenerate::basicInput('button', $btn1, 'button-grey save-entry-button search-list-entry search-button form-button ' . str_replace('_', '-', $btn1), '', 'import', '' . $language['backend.import.feed.list'] . ' ') . '
');
$html = $list_button ? $button : $save_action;
return $html;
}
/* submit YOUTUBE video feeds */
public function processVideoFeed()
{
global $cfg;
if (isset($_POST['feed_categ'])) {
//standard feeds
$out = self::getAndPrintStandardFeeds('m1');
} else {
//channel feeds
$out = self::getAndPrintStandardFeeds('m2');
}
echo $out;
}
/* submit VIMEO user video feeds */
public function processVimeoFeed()
{
global $class_filter, $language, $cfg, $smarty, $side;
$user = $class_filter->clr_str(trim($_POST['feed_channel_vimeo']));
$type = $class_filter->clr_str($_POST['feed_type_vimeo']);
$results = $class_filter->clr_str($_POST['feed_results_vimeo']);
$smarty->assign('page_display', 'tpl_import');
switch ($results) {
case '1_-_20':$page = 1;
break;
case '21_-_40':$page = 2;
break;
case '41_-_60':$page = 3;
break;
default:$page = 1;
break;
}
$vimeo_api = 'http://vimeo.com/api/v2/' . $user . '/' . $type . '.php?page=' . $page;
$r = VServer::curl_tt($vimeo_api);
$res = unserialize($r);
$count = 1;
$checked = count($_POST['import_id']);
$error = false;
$btn1 = 'list_vimeo_feed';
$btn2 = 'import_vimeo_feed';
$usr = 'assign_username_import_vimeo_channel';
$btn = VGenerate::basicInput('button', $btn2, 'no-display save-videos-button search-button form-button ' . str_replace('_', '-', $btn2), '', 'import', $language['backend.import.feed.import']);
if ($_GET['do'] == 'import-vimeo-feed' and $checked == 0) {
$error = VGenerate::noticeTpl('', $language['backend.embed.nosel'], '');
} elseif ($_POST[$usr] == '' and $side == 'backend' and $_GET['do'] == 'import-vimeo-feed') {
$error = VGenerate::noticeTpl('', $language['backend.embed.username'], '');
}
if (is_array($res)) {
$html = '' . $html . '
';
echo $ht;
}
/* submit DAILYMOTION user and video feeds */
public function processDailymotionFeed()
{
global $class_filter, $db, $language, $smarty, $cfg, $side;
$_do = $class_filter->clr_str($_GET['do']);
$user = $class_filter->clr_str(trim($_POST['feed_channel_dm']));
$type = $class_filter->clr_str($_POST['feed_type_dm']);
$type_video = $class_filter->clr_str($_POST['feed_type_dm_video']);
$categ_video = $class_filter->clr_str($_POST['assign_category_dm_video']);
$sort_video = $class_filter->clr_str($_POST['feed_sort_dm_video']);
$region_video = $class_filter->clr_str($_POST['feed_region_dm']);
$search_video = $class_filter->clr_str($_POST['be_search_term']);
$results = ($_do == 'dm-feed' or $_do == 'import-dm-user') ? $class_filter->clr_str($_POST['feed_results_dm']) : $class_filter->clr_str($_POST['feed_results_dm_type']);
$fr = explode("-", $results);
$feed_start = substr($fr[0], 0, -1);
$feed_max = substr($fr[1], 1);
$feed_stop = 50;
$feed_page = $feed_max / $feed_stop;
$dm_api = 'https://api.dailymotion.com';
$dm_get = ($_do == 'dm-feed' or $_do == 'import-dm-user') ? '/user/' . $user . '/' . $type : '/videos';
$dm_param = '?page=' . $feed_page . '&limit=' . $feed_stop . '&fields=description,duration,tags,title,channel,thumbnail_url,thumbnail_small_url,thumbnail_medium_url,thumbnail_large_url,url,id';
if ($_do == 'dm-video' or $_do == 'import-dm-video') {
$dm_param .= ($type_video != '' ? '&filters=' . $type_video : null);
$dm_param .= ($categ_video != '' ? '&channel=' . $categ_video : null);
$dm_param .= ($sort_video != '' ? '&sort=' . $sort_video : null);
$dm_param .= ($region_video != '' ? '&language=' . $region_video : null);
$dm_param .= ($search_video != '' ? '&search=' . urlencode($search_video) : null);
}
$dm_api = $dm_api . $dm_get . $dm_param;
$rs = VServer::curl_tt($dm_api);
$res = json_decode($rs, true);
$err = $res['error']['message'] != '' ? $res['error']['message'] : false;
$error = false;
$total = count($res['list']);
$checked = is_array($_POST['import_id']) ? count($_POST['import_id']) : 0;
if ($_do == 'dm-feed' or $_do == 'import-dm-user') {
$btn1 = 'list_dailymotion_feed';
$btn2 = 'import_dailymotion_feed';
$usr = 'assign_username_import_dm_channel';
} else {
$btn1 = 'list_dailymotion_feed_video';
$btn2 = 'import_dailymotion_feed_video';
$usr = 'assign_username_import_dm_video';
}
$smarty->assign('page_display', 'tpl_import');
$btn = VGenerate::basicInput('button', $btn2, 'no-display save-videos-button search-button form-button ' . str_replace('_', '-', $btn2), '', 'import', $language['backend.import.feed.import']);
if (($_GET['do'] == 'import-dm-user' or $_GET['do'] == 'import-dm-video') and $checked == 0) {
$error = VGenerate::noticeTpl('', $language['backend.embed.nosel'], '');
} elseif ($_POST[$usr] == '' and $side == 'backend' and ($_GET['do'] == 'import-dm-user' or $_GET['do'] == 'import-dm-video')) {
$error = VGenerate::noticeTpl('', $language['backend.embed.username'], '');
}
$i = 0;
$count = 1;
$html = '';
$html .= '
';
$html .= '
';
$html .= '
';
$html .= '
';
$html .= self::selectEntries($btn1, $btn2);
$html .= $btn;
$html .= '
';
$html .= '
' . $smarty->fetch("tpl_backend/tpl_settings/ct-save-open-close.tpl") . '
';
$html .= '
';
$html .= '
'; //end left-float
$html .= '
'; //end section-top-bar
$html .= '
';
$html .= '
' . ($err != '' ? $err : $error) . '
';
$html .= '
';
foreach ($res['list'] as $k => $v) {
$dbc = $db->execute(sprintf("SELECT `ct_id`, `ct_name` FROM `db_categories` WHERE `ct_type`='video' AND `ct_active`='1' AND `ct_name` LIKE '%s' OR `ct_descr` LIKE '%s';", '%' . $v['channel'] . '%', '%' . $v['channel'] . '%'));
$db_categ_id = $dbc->fields['ct_id'];
$ct_name = $dbc->fields['ct_name'];
$tmb = array(
0 => $v['thumbnail_large_url'],
1 => $v['thumbnail_medium_url'],
2 => $v['thumbnail_medium_url'],
3 => $v['thumbnail_medium_url'],
);
$html .= '';
$html .= '';
$html .= '
';
$html .= ' 0 and in_array($v['id'], $_POST['import_id'])) ? ' checked="checked"' : null) . ' class="import-selected" value="' . $v['id'] . '" /> ';
$html .= VGenerate::simpleDivWrap('entry-title-off ct-bullet-label left-float right-padding10 link', '', '', '', 'span');
$html .= ' ';
$html .= ' ';
$html .= '
';
$html .= '
';
$html .= VGenerate::simpleDivWrap('left-float vs-column thirds', '', '
');
$html .= '
';
$html .= (!$err and !$error) ? self::saveCheck($v['id'], array(
"title" => $v['title'],
"description" => $v['description'],
"tags" => implode(" ", $v['tags']),
"category" => ((isset($_POST['assign_category_dm_type']) and $_POST['assign_category_dm_type'] != '') ? intval($_POST['assign_category_dm_type']) : ((isset($_POST['assign_category_dm']) and $_POST['assign_category_dm'] != '') ? intval($_POST['assign_category_dm']) : ($db_categ_id > 0 ? $db_categ_id : self::getOther()))),
"duration" => $v['duration'],
"key" => $v['id'],
"src" => 'dailymotion',
"url" => $v['url'],
"tmb" => $tmb)) : null;
$html .= VGenerate::simpleDivWrap('row bold embed-title', '', $v['title']);
$d = str_replace(' ', "\n", $v['description']);
$html .= VGenerate::simpleDivWrap('row embed-description', '', VUserinfo::truncateString($d, 200));
$html .= VGenerate::simpleDivWrap('row greyed-out embed-category', '', $language['backend.import.category'] . ($ct_name != '' ? $ct_name : $v['channel']));
$html .= '
';
$html .= '
';
$html .= '
';
$html .= ' ';
$count++;
}
$html .= ' ';
$html .= '
';
$html .= VGenerate::declareJS(self::grabberjs());
$html .= '';
$ht = '' . $html . '
';
echo $ht;
}
private static function durationFromString($string)
{
if (is_array($string) and isset($string[0])) {
$string = $string[0];
}
if (substr($string, 0, 2) === "PT") {
$period = new DateInterval($string);
$totalSeconds = $period->s + $period->i * 60;
} else {
if (strpos($string, ":") !== false) {
$exp = explode(":", $string);
$ext = count($exp);
if ($ext == 2) {
$hours = 0;
list($minutes, $seconds) = $exp;
} elseif ($ext == 3) {
list($hours, $minutes, $seconds) = $exp;
}
$totalSeconds = $hours * 3600 + $minutes * 60 + $seconds;
} else {
$totalSeconds = $string;
}
}
return (float) $totalSeconds;
}
private static function extractUniqueWords($inputArray, $limit = 10)
{
$uniqueWords = array();
$count = 0;
foreach ($inputArray as $text) {
$words = explode(" ", $text);
foreach ($words as $word) {
// Remove non-alphanumeric characters and convert to lowercase
$word = strtolower(preg_replace('/[^a-zA-Z0-9]/', '', $word));
// Check if the word is longer than 4 characters and not in the $uniqueWords array
if (strlen($word) > 4 && !in_array($word, $uniqueWords)) {
$uniqueWords[] = $word;
$count++;
}
// Stop after reaching the specified limit
if ($count >= $limit) {
break 2; // Break both the inner and outer loops
}
}
}
return $uniqueWords;
}
/* submit single video embed */
public function processVideoEmbed()
{
global $class_filter, $language, $cfg;
require_once 'f_core/f_classes/class_oembed/vendor/autoload.php';
// $video_url = $class_filter->clr_str($_POST['be_video_url']);
$video_url = htmlspecialchars($_POST['be_video_url']);
$video_categ = $class_filter->clr_str($_POST['assign_category_file']);
$u = parse_url($video_url);
$h = explode('.', $u['host']);
$src = $h[(count($h) - 2)];
$src = ($src == 'youtu' ? 'youtube' : $src);
$data = array();
$duration = null;
$short = 0;
try {
$embed = new Embed();
$info = $embed->get($video_url);
$title = $info->title;
$thumb = $info->image;
$code = $info->code->html;
$description = $info->description ?: $title;
$tags = $info->keywords ?: $title;
if ($src == 'facebook') {
$metas = $info->getMetas()->all();
$title = $metas['og:title'][0];
$description = $metas['og:description'][0];
$thumb = $metas['og:image'][0];
$tags = implode(' ', self::extractUniqueWords(array_slice($metas['og:title'], 0, 10)));
$code = '' . $html . '
';
}
public function printVideoFeed($videoFeed, $feed_type)
{
global $class_filter, $language, $cfg, $smarty, $side;
$error = false;
$count = 1;
if (is_array($videoFeed) and count($videoFeed) == 0) {
return false;
}
$smarty->assign('page_display', 'tpl_import');
$checked = is_array($_POST['import_id']) ? count($_POST['import_id']) : 0;
switch ($feed_type) {
case "m1":
$form = 'video-feed-form';
$btn1 = 'list_video_feed';
$btn2 = 'import_video_feed';
$usr = 'assign_username_import_yt_video';
break;
case "m2":
$form = 'channel-feed-form';
$btn1 = 'list_channel_feed';
$btn2 = 'import_channel_feed';
$usr = 'assign_username_import_yt_channel';
break;
}
$btn = VGenerate::basicInput('button', $btn2, 'no-display save-videos-button search-button form-button ' . str_replace('_', '-', $btn2), '', 'import', $language['backend.import.feed.import']);
if (($_GET['do'] == 'import-yt-channel' or $_GET['do'] == 'import-yt-video') and $checked == 0) {
$error = VGenerate::noticeTpl('', $language['backend.embed.nosel'], '');
} elseif ($_POST[$usr] == '' and $side == 'backend' and ($_GET['do'] == 'import-yt-channel' or $_GET['do'] == 'import-yt-video')) {
$error = VGenerate::noticeTpl('', $language['backend.embed.username'], '');
}
$html = null;
$html .= '';
$html .= '
';
$html .= '
';
$html .= '
';
$html .= '
';
$html .= self::selectEntries($btn1, $btn2);
$html .= $btn;
$html .= '
';
$html .= '
' . $smarty->fetch("tpl_backend/tpl_settings/ct-save-open-close.tpl") . '
';
$html .= '
';
$html .= '
'; //end left-float
$html .= '
'; //end section-top-bar
$html .= '
';
$html .= '
' . $error . '
';
$html .= '
';
foreach ($videoFeed as $videoEntry) {
if (is_array($videoEntry)) {
foreach ($videoEntry as $k => $videoEntryDetails) {
if ($k >= 0) {
$_id = $videoEntryDetails->id->videoId;
$_title = $videoEntryDetails->id->videoTitle;
$html .= '';
$html .= '';
$html .= '
';
$html .= ' 0 and in_array($_id, $_POST['import_id'])) ? ' checked="checked"' : null) . ' class="import-selected" value="' . $_id . '" /> ';
$html .= VGenerate::simpleDivWrap('entry-title-off ct-bullet-label left-float right-padding10 link', '', $_title, '', 'span');
$html .= ' ';
$html .= ' ';
$html .= '
';
$html .= '
';
$html .= VGenerate::simpleDivWrap('left-float vs-column thirds', '', '
');
$html .= '
';
$html .= self::printVideoEntry($videoFeed, $_id, $error);
$html .= '
';
$html .= '
';
$html .= '
';
$html .= ' ';
$count++;
}
}
}
}
$html .= ' ';
$html .= '
';
$nextPageToken = $videoFeed->nextPageToken;
$prevPageToken = $videoFeed->prevPageToken;
$currentPageToken = isset($_GET['token']) ? $class_filter->clr_str($_GET['token']) : null;
$pjsct = $prevPageToken != '' ? '