/** * Outputs frontpage HTML * * @return Nothing */ function grabAjaxPlayer() { global $Itemid, $smartyvs, $hwdvs_selectv, $hwdvs_joinv, $mainframe, $hwdvsAjaxPlayer; header('Content-type: text/html; charset=utf-8'); $c = hwd_vs_Config::get_instance(); $db = & JFactory::getDBO(); $my = & JFactory::getUser(); $acl= & JFactory::getACL(); $usersConfig = &JComponentHelper::getParams( 'com_users' ); $video_id = JRequest::getInt( 'video_id', 0 ); $template = JRequest::getVar( 'template', '' ); $showdetails = JRequest::getInt( 'showdetails', '1' ); $width = JRequest::getInt( 'width', null ); $height = JRequest::getInt( 'height', null ); $quality = JRequest::getWord( 'quality', 'hd' ); $autostart = JRequest::getInt( 'autostart', null ); $hwdvsAjaxPlayer = true; if (!hwd_vs_access::allowAccess( $c->gtree_plyr, $c->gtree_plyr_child, hwd_vs_access::userGID( $my->id ))) { if ( ($my->id < 1) && (!$usersConfig->get( 'allowUserRegistration' ) == '0' && hwd_vs_access::allowAccess( $c->gtree_upld, 'RECURSE', $acl->get_group_id('Registered','ARO') ) ) ) { hwd_vs_tools::infomessage(1, 0, _HWDVIDS_TITLE_NOACCESS, _HWDVIDS_ALERT_REGISTERFORPLYR, "exclamation.png", 0, 0); exit; } else { hwd_vs_tools::infomessage(1, 0, _HWDVIDS_TITLE_NOACCESS, _HWDVIDS_ALERT_PLYR_NOT_AUTHORIZED, "exclamation.png", 0, 0); exit; } } $where = ' WHERE video.id = '.$video_id; $query = "SELECT".$hwdvs_selectv." FROM #__hwdvidsvideos AS video ".$hwdvs_joinv." ".$where; $db->SetQuery($query); $row = $db->loadObject(); if (!hwd_vs_tools::validateVideoAccess($row)) { exit; } hwd_vs_tools::logViewing($row->id); require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'libraries'.DS.'maintenance_recount.class.php'); if ($showdetails == 1) { $smartyvs->assign("showdetails", 1); } $videoplayer = hwd_vs_tools::generateVideoDetails($row, $width, $height, null, $Itemid, null, null, $autostart); $smartyvs->assign("videoplayer", $videoplayer); hwd_vs_javascript::ajaxRate($row); if (empty($template) || $template == '') { $html = $smartyvs->fetch('plug_jomsocial_ajax.tpl'); } else if ($template == 'playeronly') { $html = $videoplayer->player; } else { $html = $smartyvs->fetch($template.'.tpl'); } print $html; exit; }
/** * Check video player access and cache settings and query SQL for video data * * @return Nothing */ function viewvideo() { global $hwdvs_joinv, $hwdvs_selectv, $smartyvs, $mainframe, $isModerator; $c = hwd_vs_Config::get_instance(); $db = & JFactory::getDBO(); $my = & JFactory::getUser(); $acl= & JFactory::getACL(); $usersConfig = &JComponentHelper::getParams( 'com_users' ); // check component access settings and deny those without privileges if (!hwd_vs_access::allowAccess( $c->gtree_plyr, $c->gtree_plyr_child, hwd_vs_access::userGID( $my->id ))) { if ( ($my->id < 1) && (!$usersConfig->get( 'allowUserRegistration' ) == '0' && hwd_vs_access::allowAccess( $c->gtree_upld, 'RECURSE', $acl->get_group_id('Registered','ARO') ) ) ) { $smartyvs->assign("showconnectionbox", 1); hwd_vs_tools::infomessage(1, 0, _HWDVIDS_TITLE_NOACCESS, _HWDVIDS_ALERT_REGISTERFORPLYR, "exclamation.png", 1); return; } else { $smartyvs->assign("showconnectionbox", 1); hwd_vs_tools::infomessage(1, 0, _HWDVIDS_TITLE_NOACCESS, _HWDVIDS_ALERT_PLYR_NOT_AUTHORIZED, "exclamation.png", 1); return; } } // get video id from POST array $video_id = JRequest::getInt( 'video_id', 0 ); // check video can be viewed by user $where = ' WHERE video.id = '.$video_id; $query = 'SELECT'.$hwdvs_selectv . ' FROM #__hwdvidsvideos AS video' . $hwdvs_joinv . $where . ' ORDER BY video.date_uploaded DESC' ; $db->SetQuery($query); $row = $db->loadObject(); if (!hwd_vs_tools::validateVideoAccess($row)) { return; } // get view count hwd_vs_tools::logViewing($video_id); require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'libraries'.DS.'maintenance_recount.class.php'); hwd_vs_recount::recountVideoViews($video_id); // get more videos from user if ($c->showuldr == "1") { $query = 'SELECT'.$hwdvs_selectv . ' FROM #__hwdvidsvideos AS video' . $hwdvs_joinv . ' WHERE video.user_id = '.$row->user_id . ' AND video.published = 1' . ' AND video.approved = "yes"' . ' AND video.id <> '.$row->id . ' ORDER BY video.date_uploaded DESC' . ' LIMIT 0, '.$c->mbtu_no ; $db->SetQuery($query); $userrows = $db->loadObjectList(); } else { $userrows = null; } // get related videos if ($c->showrevi == "1") { $searchterm = addslashes($row->title." ".$row->description." ".$row->tags); require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'helpers'.DS.'search.php'); $whereVideos = hwd_vs_search::search_perform_videos("related",$searchterm); // get matching video data $query = 'SELECT'.$hwdvs_selectv . ' FROM #__hwdvidsvideos AS video' . $hwdvs_joinv . $whereVideos . ' AND video.published = 1' . ' AND video.approved = "yes"' . ' AND video.id <> '.$row->id //. ' ORDER BY video.date_uploaded DESC' . ' LIMIT 0, '.$c->revi_no ; $db->SetQuery($query); $relatedrows = $db->loadObjectList(); } else { $relatedrows = null; } // get more from category if ( $c->cvordering == "orderASC" ) { $order = ' ORDER BY video.ordering ASC'; } else if ( $c->cvordering == "orderDESC" ) { $order = ' ORDER BY video.ordering DESC'; } else if ( $c->cvordering == "dateASC" ) { $order = ' ORDER BY video.date_uploaded ASC'; } else if ( $c->cvordering == "dateDESC" ) { $order = ' ORDER BY video.date_uploaded DESC'; } else if ( $c->cvordering == "nameASC" ) { $order = ' ORDER BY video.title ASC'; } else if ( $c->cvordering == "nameDESC" ) { $order = ' ORDER BY video.title DESC'; } else if ( $c->cvordering == "hitsASC" ) { $order = ' ORDER BY video.number_of_views ASC'; } else if ( $c->cvordering == "hitsDESC" ) { $order = ' ORDER BY video.number_of_views DESC'; } else if ( $c->cvordering == "voteASC" ) { $order = ' ORDER BY video.updated_rating ASC'; } else if ( $c->cvordering == "voteDESC" ) { $order = ' ORDER BY video.updated_rating DESC'; } else { $order = ' ORDER BY video.date_uploaded DESC'; } if ($c->showmftc == "1") { $query = 'SELECT'.$hwdvs_selectv . ' FROM #__hwdvidsvideos AS video' . $hwdvs_joinv . ' WHERE video.category_id = '.$row->category_id . ' AND video.published = 1' . ' AND video.approved = "yes"' . ' AND video.id <> '.$row->id . $order . ' LIMIT 0, '.$c->mftc_no ; $db->SetQuery($query); $categoryrows = $db->loadObjectList(); } else { $categoryrows = null; } // send out hwd_vs_html::viewVideo($row, $userrows, $relatedrows, $categoryrows); }
/** * Generates the array of information for a standard video list from sql queries * * @param array $rows the list from a standard sql queries * @param string $thumbclass(optional) the class for the thumbnail images * @param int $thumbwidth(optional) the thumbnail width * @param int $thumbheight(optional) the thumbnail height * @return $code the array prepared for Smarty template */ function generateVideoListFromSql( $rows, $thumbclass=null, $thumbwidth=null, $thumbheight=null, $hwdvs_itemid=null, $onclick_js=null, $tooltip=null, $or_title_trunc=null, $or_descr_trunc=null, $lightbox=false) { global $hwdvsTemplateOverride; $acl= & JFactory::getACL(); $usersConfig = &JComponentHelper::getParams( 'com_users' ); $c = hwd_vs_Config::get_instance(); if (isset($tooltip) && !$tooltip) { $tooltip = 0; } else if ($tooltip || $c->show_tooltip == "1") { $tooltip = 1; } $code = array(); $k = 0; if (isset($thumbwidth)) { $twidth = $thumbwidth; } else { $twidth = null; } if (isset($thumbheight)) { $theight = $thumbheight; } else { $theight = null; } if (isset($thumbclass)) { $tclass = $thumbclass; } else { $tclass = null; } if (isset($or_title_trunc) && !empty($or_title_trunc)) { $truntitle = $or_title_trunc; } else { $truntitle = $c->truntitle; } if (isset($or_descr_trunc) && !empty($or_descr_trunc)) { $trunvdesc = $or_descr_trunc; } else { $trunvdesc = $c->trunvdesc; } $width = null; $height = null; $class = null; $tooltip_data = null; for ($i=0, $n=count($rows); $i < $n; $i++) { $row = $rows[$i]; if ($c->bviic == 1) { if (!hwd_vs_tools::validateVideoAccess($row, false)) { continue; } } if (!isset($row->avatar)) { $row->avatar = null; } if (!isset($row->username)) { $row->username = ''; } if (!isset($row->name)) { $row->name = ''; } if ($hwdvsTemplateOverride['show_avatar'] == 1) { $code[$i]->avatar = hwd_vs_tools::generateAvatar($row->user_id, $row->avatar, $k, $width, $height, $class); } if ($hwdvsTemplateOverride['show_title']) { $code[$i]->title = hwd_vs_tools::generateVideoLink( $row->id, $row->title, $hwdvs_itemid, $onclick_js, $truntitle); } if ($hwdvsTemplateOverride['show_category']) { $code[$i]->category = hwd_vs_tools::generateCategoryLink($row->category_id); } if ($hwdvsTemplateOverride['show_description']) { $code[$i]->description = hwd_vs_tools::truncateText(strip_tags(stripslashes($row->description)), $trunvdesc); } $tooltip_data[0] = $tooltip; $tooltip_data[1] = htmlspecialchars(strip_tags(stripslashes($row->title))); $tooltip_data[2] = hwd_vs_tools::truncateText(htmlspecialchars(strip_tags(stripslashes($row->description))), $trunvdesc); if ($hwdvsTemplateOverride['show_rating'] == 1 && $row->allow_ratings == 1 && $c->showrate == 1) { $code[$i]->rating = hwd_vs_tools::generateRatingImg($row->updated_rating); $code[$i]->showrating = 1; } if ($hwdvsTemplateOverride['show_thumbnail'] == 1) { $code[$i]->thumbnail = hwd_vs_tools::generateVideoThumbnailLink($row->id, $row->video_id, $row->video_type, $row->thumbnail, $k, $twidth, $theight, $tclass, null, $hwdvs_itemid, $onclick_js, $tooltip_data, $lightbox, $row->video_length); } if ($hwdvsTemplateOverride['show_views']) { $code[$i]->views = $row->number_of_views; } if ($hwdvsTemplateOverride['show_comments']) { $code[$i]->comments = $row->number_of_comments; } if ($hwdvsTemplateOverride['show_duration']) { $code[$i]->duration = $row->video_length; } if ($hwdvsTemplateOverride['show_uploader']) { $code[$i]->uploader = hwd_vs_tools::generateUserFromID($row->user_id, $row->username, $row->name); } if ($hwdvsTemplateOverride['show_timesince']) { $code[$i]->timesince = hwd_vs_tools::generateTimeSinceUpload($row->date_uploaded); } if ($hwdvsTemplateOverride['show_upload_date']) { $code[$i]->upload_date = strftime("%l%P - %b %e, %Y", strtotime($row->date_uploaded)); } if ($hwdvsTemplateOverride['show_tags']) { $code[$i]->tags = hwd_vs_tools::generateTagListString($row->tags); } $code[$i]->deletevideo = hwd_vs_tools::generateDeleteVideoLink($row); $code[$i]->editvideo = hwd_vs_tools::generateEditVideoLink($row); $code[$i]->publishvideo = hwd_vs_tools::generatePublishVideoLink($row); $code[$i]->approvevideo = hwd_vs_tools::generateApproveVideoLink($row); $code[$i]->counter = $i; $code[$i]->k = $k; $k = 1 - $k; } return $code; }