diff --git a/plugin/LiveLinks/LiveLinks.php b/plugin/LiveLinks/LiveLinks.php
index bd68ca958..7ac1cffc8 100644
--- a/plugin/LiveLinks/LiveLinks.php
+++ b/plugin/LiveLinks/LiveLinks.php
@@ -1,441 +1,441 @@
isReadyLabel(array('Live'));
$help = "
Help";
return $desc . $help;
}
public function getName() {
return "LiveLinks";
}
public function getEmptyDataObject() {
global $global;
$obj = new stdClass();
$obj->onlyAdminCanAddLinks = true;
$obj->buttonTitle = "Add a Live Link";
$obj->disableGifThumbs = false;
$obj->disableLiveThumbs = false;
$obj->doNotShowLiveLinksLabel = false;
$obj->disableProxy = false;
$obj->hideTopButton = true;
self::addDataObjectHelper('hideTopButton', 'Hide Top Button', 'This will hide the button on the top menu bar');
return $obj;
}
public function getUUID() {
return "39d3b5fe-9702-4f1d-9ffd-fe1cd22a4dc7";
}
public function getPluginVersion() {
return "4.0";
}
public function canAddLinks() {
$obj = $this->getDataObject();
if (!User::isLogged()) {
return false;
}
if ($obj->onlyAdminCanAddLinks && !User::isAdmin()) {
return false;
}
return User::canStream();
}
public function getHTMLMenuRight() {
global $global;
$obj = $this->getDataObject();
if($obj->hideTopButton){
return '';
}
if (!$this->canAddLinks()) {
return '';
}
include $global['systemRootPath'] . 'plugin/LiveLinks/view/menuRight.php';
}
static function getAllActive($future = false, $activeOnly = true, $notStarted = false) {
global $global;
_mysql_connect();
$sql = "SELECT * FROM LiveLinks WHERE 1=1 ";
if (!empty($future)) {
$sql .= " AND end_date >= now() ";
}
if (!empty($activeOnly)) {
$sql .= " AND status='a' ";
}
if (!empty($notStarted)) {
$sql .= " AND start_date >= now() ";
}
$sql .= " ORDER BY start_date ";
//echo $sql;//exit;
$res = $global['mysqli']->query($sql);
$rows = array();
if ($res) {
while ($row = $res->fetch_assoc()) {
$rows[] = $row;
}
} else {
die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
}
return $rows;
}
static function getImage($id) {
global $global;
return "{$global['webSiteRootURL']}plugin/LiveLinks/getImage.php?id={$id}&format=jpg";
}
static function getImageGif($id) {
global $global;
return "{$global['webSiteRootURL']}plugin/LiveLinks/getImage.php?id={$id}&format=webp";
}
/**
*
* @return type array(array("key"=>'live key', "users"=>false, "name"=>$userName, "user"=>$user, "photo"=>$photo, "UserPhoto"=>$UserPhoto, "title"=>''));
*/
public function getLiveApplicationArray() {
global $global;
$liveUsers = AVideoPlugin::isEnabledByName('LiveUsers');
$row = LiveLinks::getAllActive(true, true);
-
+ $array = array();
foreach ($row as $value) {
if ($value['type'] == 'unlisted') {
continue;
}
if ($value['type'] == 'logged_only') {
if (!User::isLogged()) {
continue;
}
}
$label = ($liveUsers ? getLiveUsersLabelLiveLinks($value['id']) : '');
//var_dump( self::getPosterToLiveFromId($value['id']),$value['id'] );exit;
$array[] = Live::getLiveApplicationModelArray(
$value['users_id'],
$value['title'],
self::getLinkToLiveFromId($value['id']),
self::getPosterToLiveFromId($value['id']),
self::getPosterToLiveFromId($value['id'], 'webp'),
'LiveLink',
$label,
'liveLink_'.$value['id'],
'',
$value['start_date']);
}
return $array;
}
public function updateScript() {
global $global;
if (AVideoPlugin::compareVersion($this->getName(), "2") < 0) {
$sqls = file_get_contents($global['systemRootPath'] . 'plugin/LiveLinks/install/updateV2.0.sql');
$sqlParts = explode(";", $sqls);
foreach ($sqlParts as $value) {
sqlDal::writeSql(trim($value));
}
}
if (AVideoPlugin::compareVersion($this->getName(), "3.1") < 0) {
$sqls = file_get_contents($global['systemRootPath'] . 'plugin/LiveLinks/install/updateV3.0.sql');
$sqlParts = explode(";", $sqls);
foreach ($sqlParts as $value) {
sqlDal::writeSql(trim($value));
}
}
return true;
}
public function getHeadCode() {
global $global;
$obj = $this->getDataObject();
// preload image
$js = "";
$css = '';
if (!empty($obj->doNotShowLiveLinksLabel)) {
$css .= '';
}
return $js . $css;
}
public static function getLinkToLiveFromId($id, $embed = false) {
return self::getLink($id, $embed);
}
public static function getLink($id, $embed = false) {
global $global;
//return "{$global['webSiteRootURL']}plugin/LiveLinks/view/Live.php?link={$id}".($embed?"&embed=1":"");
$ll = new LiveLinksTable($id);
if (!$embed) {
return "{$global['webSiteRootURL']}liveLink/{$id}/" . urlencode(cleanURLName($ll->getTitle()));
} else {
return "{$global['webSiteRootURL']}liveLinkEmbed/{$id}/" . urlencode(cleanURLName($ll->getTitle()));
}
}
public static function getSourceLink($id) {
global $global;
if (empty($id)) {
return false;
}
$ll = new LiveLinksTable($id);
if (empty($ll->getLink())) {
return false;
}
$liveLink = 'Invalid livelink' . $id;
if (filter_var($ll->getLink(), FILTER_VALIDATE_URL)) {
$url = parse_url($ll->getLink());
if ($url['scheme'] == 'https') {
$liveLink = $ll->getLink();
} else {
$liveLink = "{$global['webSiteRootURL']}plugin/LiveLinks/proxy.php?livelink=" . urlencode($ll->getLink());
}
}
return $liveLink;
}
public function getPosterToLiveFromId($id, $format = 'jpg') {
global $global;
return "{$global['webSiteRootURL']}plugin/LiveLinks/getImage.php?id={$id}&format={$format}";
}
public static function isLiveThumbsDisabled() {
$obj = AVideoPlugin::getDataObject("LiveLinks");
if (!empty($obj->disableLiveThumbs)) {
return true;
}
return false;
}
public function getPosterThumbsImage($users_id, $live_servers_id) {
global $global;
$file = Live::_getPosterThumbsImage($users_id, $live_servers_id);
if (!file_exists($global['systemRootPath'] . $file)) {
$file = "plugin/Live/view/OnAir.jpg";
}
return $file;
}
public function getUploadMenuButton() {
global $global;
if (!$this->canAddLinks()) {
return '';
}
$obj = $this->getDataObject();
$buttonTitle = $obj->buttonTitle;
include $global['systemRootPath'] . 'plugin/LiveLinks/getUploadMenuButton.php';
}
public static function getAllVideos($status = "", $showOnlyLoggedUserVideos = false, $activeUsersOnly = true) {
global $global, $config, $advancedCustom;
if (AVideoPlugin::isEnabledByName("VideoTags")) {
if (!empty($_GET['tags_id']) && empty($videosArrayId)) {
TimeLogStart("video::getAllVideos::getAllVideosIdFromTagsId({$_GET['tags_id']})");
$videosArrayId = VideoTags::getAllVideosIdFromTagsId($_GET['tags_id']);
TimeLogEnd("video::getAllVideos::getAllVideosIdFromTagsId({$_GET['tags_id']})", __LINE__);
}
}
$status = str_replace("'", "", $status);
$sql = "SELECT u.*, v.*, c.iconClass, c.name as category, c.clean_name as clean_category,c.description as category_description, v.created as videoCreation, v.modified as videoModified "
. " FROM LiveLinks as v "
. " LEFT JOIN categories c ON categories_id = c.id "
. " LEFT JOIN users u ON v.users_id = u.id "
. " WHERE 1=1 ";
if ($showOnlyLoggedUserVideos === true && !Permissions::canModerateVideos()) {
$uid = intval(User::getId());
$sql .= " AND v.users_id = '{$uid}'";
} elseif (!empty($showOnlyLoggedUserVideos)) {
$uid = intval($showOnlyLoggedUserVideos);
$sql .= " AND v.users_id = '{$uid}'";
} elseif (!empty($_GET['channelName'])) {
$user = User::getChannelOwner($_GET['channelName']);
$uid = intval($user['id']);
$sql .= " AND v.users_id = '{$uid}' ";
}
if ($activeUsersOnly) {
$sql .= " AND u.status = 'a' ";
}
if ($status == "publicOnly") {
$sql .= " AND v.`type` = 'public' ";
} elseif (!empty($status)) {
$sql .= " AND v.`status` = '{$status}'";
}
if (!empty($_GET['catName'])) {
$catName = $global['mysqli']->real_escape_string($_GET['catName']);
$sql .= " AND (c.clean_name = '{$catName}' OR c.parentId IN (SELECT cs.id from categories cs where cs.clean_name = '{$catName}' ))";
}
if (!empty($_GET['modified'])) {
$_GET['modified'] = str_replace("'", "", $_GET['modified']);
$sql .= " AND v.modified >= '{$_GET['modified']}'";
}
$sql .= AVideoPlugin::getVideoWhereClause();
if (strpos(strtolower($sql), 'limit') === false) {
if (!empty($_GET['limitOnceToOne'])) {
$sql .= " LIMIT 1";
unset($_GET['limitOnceToOne']);
} else {
$_REQUEST['rowCount'] = getRowCount();
if (!empty($_REQUEST['rowCount'])) {
$sql .= " LIMIT {$_REQUEST['rowCount']}";
} else {
_error_log("getAllVideos without limit " . json_encode(debug_backtrace()));
if (empty($global['limitForUnlimitedVideos'])) {
$global['limitForUnlimitedVideos'] = 100;
}
if ($global['limitForUnlimitedVideos'] > 0) {
$sql .= " LIMIT {$global['limitForUnlimitedVideos']}";
}
}
}
}
//echo $sql;exit;
//_error_log("getAllVideos($status, $showOnlyLoggedUserVideos , $ignoreGroup , ". json_encode($videosArrayId).")" . $sql);
$res = sqlDAL::readSql($sql);
$fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res);
$videos = array();
if ($res != false) {
foreach ($fullData as $row) {
$row = cleanUpRowFromDatabase($row);
if (empty($otherInfo)) {
$otherInfo = array();
$otherInfo['category'] = xss_esc_back($row['category']);
//$otherInfo['groups'] = UserGroups::getVideoGroups($row['id']);
//$otherInfo['title'] = UTF8encode($row['title']);
$otherInfo['description'] = UTF8encode($row['description']);
$otherInfo['descriptionHTML'] = Video::htmlDescription($otherInfo['description']);
$otherInfo['filesize'] = 0;
}
foreach ($otherInfo as $key => $value) {
$row[$key] = $value;
}
$row['rotation'] = 0;
$row['filename'] = '';
$row['type'] = 'livelinks';
$row['duration'] = '';
$row['isWatchLater'] = 0;
$row['isFavorite'] = 0;
$row['views_count'] = 0;
$videos[] = $row;
}
//$videos = $res->fetch_all(MYSQLI_ASSOC);
} else {
$videos = false;
die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
}
return $videos;
}
static function notifySocketToRemoveLiveLinks($liveLinks_id) {
$array = array();
$array['stats'] = getStatsNotifications();
$array['autoEvalCodeOnHTML'] = '$(".liveLink_' . $liveLinks_id . '").slideUp();';
$socketObj = sendSocketMessageToAll($array, 'socketRemoveLiveLinks');
return $socketObj;
}
public function getFooterCode() {
$obj = $this->getDataObject();
global $global;
include $global['systemRootPath'] . 'plugin/LiveLinks/view/footer.php';
return '';
}
static function userCanWatch($users_id, $livelinks_id) {
if (empty($users_id) || empty($livelinks_id)) {
return false;
}
if (User::isAdmin()) {
return true;
}
$livelinks = new LiveLinksTable($livelinks_id);
if ($livelinks->getUsers_id() == $users_id) {
return true;
}
$user_groups_ids = LiveLinksTable::getUserGorupsIds($livelinks_id);
if (empty($user_groups_ids)) {
return true;
}
return LiveLinksTable::userGroupsMatch($livelinks_id, $users_id);
}
public static function getDinamicVideoLink($videoLink, $title, $owner_users_id) {
global $global;
$video = new stdClass();
$video->videoLink = $videoLink;
$video->title = $title;
$video->users_id = $owner_users_id;
$hash = encryptString(_json_encode($video));
return "{$global['webSiteRootURL']}liveLink/0/?hash={$hash}";
}
public static function decodeDinamicVideoLink() {
if (empty($_REQUEST['hash'])) {
return false;
}
$string = decryptString($_REQUEST['hash']);
$video = _json_decode($string);
//var_dump($video);exit;
$t = array();
$t['id'] = -1;
$t['users_id'] = $video->users_id;
$t['title'] = $video->title;
$t['link'] = $video->videoLink;
$t['description'] = @$video->description;
return $t;
}
}