/** * Outputs frontpage HTML * * @param string $option the joomla component name * @param array $rows array of video data * @param array $rowsfeatured array of featured video data * @param object $pageNav page navigation object * @param int $total the total video count * @return Nothing */ function initiate($override) { global $mainframe; // set cache variables $cachedir = JPATH_SITE.'/administrator/cache/'; // Directory to cache files in (keep outside web root) $cachetime = 86400; // Seconds to cache files for $cacheext = 'cache'; // Extension to give cached files (usually cache, htm, txt) $page = 'http://recountfile'; // Requested page $cachefile = $cachedir . md5($page) . '.' . $cacheext; // Cache file to either load or create $cachefile_created = (@file_exists($cachefile)) ? @filemtime($cachefile) : 0; @clearstatcache(); if ($override == 2) { // Show file from cache if still valid if (time() - $cachetime < $cachefile_created) { $mainframe->enqueueMessage(_HWDVIDS_M_COUNT_RUN); return; } } // Now the script has run, generate a new cache file $fp = @fopen($cachefile, 'w'); // save the contents of output buffer to the file @fwrite($fp, ob_get_contents()); @fclose($fp); hwd_vs_recount::recountVideosInCategory(); hwd_vs_recount::recountSubcatsInCategory(); hwd_vs_recount::recountMembersInGroup(); hwd_vs_recount::recountVideosInGroup(); hwd_vs_recount::recountVideoViews(); hwd_vs_recount::recountRatings(); hwd_vs_recount::recountNumberOfComments(); return true; }
/** * edit videos */ function editvideos($cid) { global $option; $db =& JFactory::getDBO(); $my = & JFactory::getUser(); $app = & JFactory::getApplication(); $row = new hwdvids_video( $db ); $row->load( $cid ); $c = hwd_vs_Config::get_instance(); // get view count require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'libraries'.DS.'maintenance_recount.class.php'); hwd_vs_recount::recountVideoViews($row->id); $db->SetQuery("SELECT *" . "\n FROM #__hwdvidsvideos" . "\n WHERE id = $cid"); $row = $db->loadObject(); $db->SetQuery("SELECT category_name" . "\n FROM #__hwdvidscategories" . "\n WHERE id = $row->category_id"); $cat = $db->loadObject(); if ($row->user_id == 0) { $usr->username = "******"; } else { $db->SetQuery("SELECT username" . "\n FROM #__users" . "\n WHERE id = $row->user_id"); $usr = $db->loadObject(); } $db->SetQuery( "SELECT count(*)" . "\nFROM #__hwdvidsfavorites" . "\nWHERE videoid = $cid" ); $favs = $db->loadResult(); echo $db->getErrorMsg(); if (empty($favs)) {$favs = 0;} $db->SetQuery( "SELECT count(*)" . "\nFROM #__hwdvidsflagged_videos" . "\nWHERE videoid = $cid" ); $flagged = $db->loadResult(); echo $db->getErrorMsg(); if (empty($flagged)) {$flagged = 0;} $upld_thumbnail = JRequest::getInt( 'upld_thumbnail', 0, 'post' ); if ($upld_thumbnail == "1") { $file_name_org = $_FILES['thumbnail_file']['name']; $file_ext = substr($file_name_org, strrpos($file_name_org, '.') + 1); if ($row->video_type == "local" || $row->video_type == "swf" || $row->video_type == "mp4") { $videocode = $row->video_id; $thumbnail = $file_ext; } else { $videocode = "tp-".$row->id; $thumbnail = "tp-".$row->id.".".$file_ext; } $base_Dir = JPATH_SITE.DS.'hwdvideos'.DS.'thumbs'.DS; $upload_result = hwd_vs_tools::uploadFile("thumbnail_file", $videocode, $base_Dir, 2, "jpg,jpeg", 1); if ($upload_result[0] == "0") { $msg = $upload_result[1]; $app->enqueueMessage($msg); $app->redirect( 'index.php?option=com_hwdvideoshare&Itemid='.$Itemid.'&task=editvidsA&hidemainmenu=1&cid='.$row->id ); } else { include_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'libraries'.DS.'thumbnail.inc.php'); $thumb_path_s = JPATH_SITE.DS.'hwdvideos'.DS.'thumbs'.DS.$videocode.'.'.$file_ext; $thumb_path_l = JPATH_SITE.DS.'hwdvideos'.DS.'thumbs'.DS.'l_'.$videocode.'.'.$file_ext; $twidth_s = round($c->con_thumb_n); $theight_s = round($c->con_thumb_n*$c->tar_fb); $twidth_l = round($c->con_thumb_l); $theight_l = round($c->con_thumb_l*$c->tar_fb); list($width, $height, $type, $attr) = @getimagesize($thumb_path_s); $ratio = $width/$height; //echo $thumb_path_s."<br />".$ratio."<br />".$width."<br />".$height."<br />".$c->tar_fb."<br />".$twidth_s."<br />".$theight_s; if ($ratio > 1) { $resized_l = new Thumbnail($thumb_path_s); $resized_l->resize($twidth_l,$twidth_l); $resized_l->cropFromCenter($twidth_l, $theight_l); $resized_l->save($thumb_path_l); $resized_l->destruct(); $resized_s = new Thumbnail($thumb_path_s); $resized_s->resize($twidth_s,$twidth_s); $resized_s->cropFromCenter($twidth_s, $theight_s); $resized_s->save($thumb_path_s); $resized_s->destruct(); } else { $resized_l = new Thumbnail($thumb_path_s); $resized_l->resize($twidth_l,2000); $resized_l->cropFromCenter($twidth_l, $theight_l); $resized_l->save($thumb_path_l); $resized_l->destruct(); $resized_s = new Thumbnail($thumb_path_s); $resized_s->resize($twidth_s,1000); $resized_s->cropFromCenter($twidth_s, $theight_s); $resized_s->save($thumb_path_s); $resized_s->destruct(); } } // update db with new thumbnail $db->SetQuery("UPDATE #__hwdvidsvideos SET thumbnail = '$thumbnail' WHERE id = $row->id"); $db->Query(); if ( !$db->query() ) { echo "<script> alert('".$db->getErrorMsg()."'); window.history.go(-1); </script>\n"; exit(); } $msg = "Thumbnail was successfully uploaded"; $app->enqueueMessage($msg); $app->redirect( 'index.php?option=com_hwdvideoshare&Itemid='.$Itemid.'&task=editvidsA&hidemainmenu=1&cid='.$row->id ); } hwdvids_HTML::editvideos($row, $cat, $usr, $favs, $flagged); }
/** * 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); }