$task = JRequest::getCmd( 'task', 'frontpage' ); $request_array = JRequest::get( 'request' ); @$cid = $request_array['cid']; hwdvsInitialise::getJVersion(); hwdvsInitialise::getMooVersion(); hwdvsInitialise::language('be'); if (!hwdvsInitialise::template('0')) {return;} hwdvsInitialise::mysqlQuery(); hwdvsInitialise::definitions(); // Check for initialisation request if ( $c->initialise_now == "1" && $task !== "initialise_now" ) { hwdvids_HTML::initialise($option); return; } else if ( $c->initialise_now == "1" && $task == "initialise_now" ) { hwdvsInitialise::initialiseSetup(); return; } // Require the base controller require_once (JPATH_COMPONENT.DS.'controller.php'); // Create the controller $controller = new UsersController( ); // Perform the Request task
/** */ function showlayoutsettings() { require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'helpers'.DS.'draw.php'); hwdvsDrawFile::generalConfig(); hwdvids_HTML::showlayoutsettings($gtree); }
/** * view the plugin page */ function plugins() { hwdvids_HTML::plugins(); return true; }
/** * Import Data */ function import() { hwdvids_HTML::importdata(); }
/** * system cleanup */ function runmaintenance() { global $limit, $limitstart; $db =& JFactory::getDBO(); $run_permdel = JRequest::getInt( 'run_permdel', 0 ); $run_fixerrors = JRequest::getInt( 'run_fixerrors', 0 ); $run_recount = JRequest::getInt( 'run_recount', 0 ); $run_archivelogs = JRequest::getInt( 'run_archivelogs', 0 ); $permdelete_report = null; $fixerrors_report = null; $recount_report = null; $archivelogs_report = null; if ($run_permdel == 1) { // permenantly delete $query = "SELECT a.*" . "\nFROM #__hwdvidsvideos AS a" . "\nWHERE a.approved = \"deleted\"" ; $db->SetQuery( $query ); $rows = $db->loadObjectList(); for($i=0, $n=count( $rows ); $i < $n; $i++) { $row = &$rows[$i]; $files = array(); $files[] = JPATH_SITE."/hwdvideos/uploads/".$row->video_id.".flv"; $files[] = JPATH_SITE."/hwdvideos/uploads/".$row->video_id.".mp4"; $files[] = JPATH_SITE."/hwdvideos/thumbs/".$row->video_id.".jpg"; $files[] = JPATH_SITE."/hwdvideos/thumbs/".$row->video_id.".gif"; $files[] = JPATH_SITE."/hwdvideos/thumbs/l_".$row->video_id.".jpg"; for($j=0, $m=count( $files ); $j < $m; $j++) { $file = &$files[$j]; if (@file_exists($file)) { @unlink($file); } } } $db->SetQuery("DELETE FROM #__hwdvidsvideos WHERE approved = \"deleted\""); $db->Query(); if ( !$db->query() ) { echo "<script> alert('".$db->getErrorMsg()."'); window.history.go(-1); </script>\n"; exit(); } $permdelete_report = true; } if ($run_fixerrors !== 0) { // perform 'fix errors' maintenance require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'libraries'.DS.'maintenance_fixerrors.class.php'); $fixerrors_report = hwd_vs_fixerrors::initiate($run_fixerrors); } if ($run_recount !== 0) { // perform 'recount' maintenance require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'libraries'.DS.'maintenance_recount.class.php'); $recount_report = hwd_vs_recount::initiate($run_recount); } // set fixerror cache variables $cachedir = JPATH_SITE.'/administrator/cache/'; // Directory to cache files in (keep outside web root) $cacheext = 'cache'; // Extension to give cached files (usually cache, htm, txt) $page = 'http://fixerrorfile'; // Requested page $cachefile = $cachedir . md5($page) . '.' . $cacheext; // Cache file to either load or create $fixerror_cache = (@file_exists($cachefile)) ? @date ("F d Y H:i:s.", filemtime($cachefile)) : "Never"; // set recount cache variables $cachedir = JPATH_SITE.'/administrator/cache/'; // Directory to cache files in (keep outside web root) $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 $recount_cache = (@file_exists($cachefile)) ? @date ("F d Y H:i:s.", filemtime($cachefile)) : "Never"; // set archive cache variables $cachedir = JPATH_SITE.'/administrator/cache/'; // Directory to cache files in (keep outside web root) $cacheext = 'cache'; // Extension to give cached files (usually cache, htm, txt) $page = 'http://archivefile'; // Requested page $cachefile = $cachedir . md5($page) . '.' . $cacheext; // Cache file to either load or create $archive_cache = (@file_exists($cachefile)) ? @date ("F d Y H:i:s.", filemtime($cachefile)) : "Never"; $db->SetQuery( "SELECT count(*)" . "\nFROM #__hwdvidsvideos AS a" . "\nWHERE a.approved = \"deleted\"" ); $total = $db->loadResult(); echo $db->getErrorMsg(); hwdvids_HTML::maintenance($permdelete_report, $total, $fixerrors_report, $recount_report, $archivelogs_report, $fixerror_cache, $recount_cache, $archive_cache); }
/** * edit categories */ function editcategories($cid) { global $option; $db = & JFactory::getDBO(); $my = & JFactory::getUser(); $acl= & JFactory::getACL(); $app = & JFactory::getApplication(); $row = new hwdvids_cats( $db ); $row->load( $cid ); // fail if checked out not by 'me' if ($row->isCheckedOut( $my->id )) { //BUMP needs change for multilanguage support $app->enqueueMessage('This category is being editted by another user'); $app->redirect( JURI::root( true ) . '/administrator/index.php?option='.$option.'&task=categories' ); } $db->SetQuery("SELECT * FROM #__hwdvidscategories" . "\nWHERE id = $cid"); $db->loadObject($row); if ($cid) { $row->checkout( $my->id ); } else { $row->published = 1; } $gtree=array(); $gtree[] = JHTML::_('select.option', -2 , '- ' ._HWDVIDS_SELECT_EVERYONE . ' -'); // '- Everybody -' $gtree[] = JHTML::_('select.option', -1, '- ' . _HWDVIDS_SELECT_ALLREGUSER . ' -'); // '- All Registered Users -' $gtree = array_merge( $gtree, $acl->get_group_children_tree( null, 'USERS', false )); $categoryList = hwd_vs_tools::categoryList(_HWDVIDS_SELECT_NOPAR, $row->parent, _HWDVIDS_INFO_NOCATS, 0, "parent", 0); hwdvids_HTML::editcategories($row, $gtree, $categoryList); }
/** * watch flagged videos */ function watchflaggedvideo() { hwdvids_HTML::watchflaggedvideo(); }
function frontpage() { global $mainframe, $limitstart, $Itemid; $db =& JFactory::getDBO(); $stats = array(); $db->setQuery( "SELECT count(*) FROM #__hwdvidsvideos WHERE approved = \"pending\"" ); $stats['approvals'] = $db->loadResult(); $db->SetQuery( "SELECT count(*) FROM #__hwdvidsvideos WHERE approved = \"queuedforconversion\" AND approved = \"queuedforthumbnail\"" ); $stats['conversion'] = $db->loadResult(); $db->SetQuery( "SELECT count(*) FROM #__hwdvidsflagged_videos WHERE status = \"UNREAD\"" ); $stats['reportedvideos'] = $db->loadResult(); $db->SetQuery( "SELECT count(*) FROM #__hwdvidsflagged_groups WHERE status = \"UNREAD\"" ); $stats['reportedgroups'] = $db->loadResult(); $db->SetQuery( "SELECT count(*) FROM #__hwdvidsvideos" ); $stats['totalvideos'] = $db->loadResult(); $db->SetQuery( "SELECT count(*) FROM #__hwdvidscategories" ); $stats['totalcategories'] = $db->loadResult(); $db->SetQuery( "SELECT count(*) FROM #__users" ); $stats['totalusers'] = $db->loadResult(); $db->SetQuery( "SELECT id FROM #__users ORDER BY registerDate DESC" ); $stats['latestuser'] = hwd_vs_tools::generateBEUserFromID($db->loadResult()); $db->SetQuery( "SELECT count(*) FROM #__hwdvidsgroups" ); $stats['totalgroups'] = $db->loadResult(); $db->SetQuery( "SELECT id, group_name FROM #__hwdvidsgroups ORDER BY date DESC" ); $latestgroup = $db->loadObject(); if (!empty($latestgroup->id)) { $stats['latestgroup'] = "<a href=\"index.php?option=com_hwdvideoshare&task=editgrpA&hidemainmenu=1&cid=".$latestgroup->id."\">$latestgroup->group_name</a>"; } else { $stats['latestgroup']=null; } $db->SetQuery( "SELECT count(*) FROM #__hwdvidsvideos WHERE date_uploaded >= DATE_SUB(NOW(),INTERVAL 1 DAY)" ); $stats['totalvideostoday'] = $db->loadResult(); $db->SetQuery( "SELECT count(*) FROM #__hwdvidsvideos WHERE date_uploaded >= DATE_SUB(NOW(),INTERVAL 7 DAY)" ); $stats['totalvideosweek'] = $db->loadResult(); $db->SetQuery( "SELECT count(*) FROM #__hwdvidslogs_views" ); $views_30 = $db->loadResult(); $db->SetQuery( "SELECT SUM(views) FROM #__hwdvidslogs_archive" ); $views_all = $db->loadResult(); $stats['totalviews'] = $views_30 + $views_all; $db->SetQuery( "SELECT count(*) FROM #__hwdvidslogs_favours" ); $favours_30 = $db->loadResult(); $db->SetQuery( "SELECT SUM(favours) FROM #__hwdvidslogs_archive" ); $favours_all = $db->loadResult(); $stats['totalfavours'] = $favours_30 + $favours_all; $db->SetQuery( "SELECT * FROM #__hwdvidsvideos ORDER BY updated_rating DESC, rating_number_votes DESC LIMIT 0, 10" ); $mostpopular = $db->loadObjectList(); $db->SetQuery( "SELECT * FROM #__hwdvidsvideos ORDER BY number_of_views DESC LIMIT 0, 10" ); $mostviewed = $db->loadObjectList(); $db->SetQuery( "SELECT * FROM #__hwdvidsvideos ORDER BY date_uploaded DESC LIMIT 0, 10" ); $mostrecent = $db->loadObjectList(); $db->SetQuery( "SELECT * FROM #__hwdvidsgroups ORDER BY date DESC LIMIT 0, 10" ); $recentgroups = $db->loadObjectList(); hwdvids_HTML::frontpage($stats, $mostpopular, $mostviewed, $mostrecent, $recentgroups); }
/** * 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); }
/** * watch unapproved videos */ function watchvideo() { hwdvids_HTML::watchvideo(); }
/** * edit categories */ function editgroups($cid) { global $option; $db =& JFactory::getDBO(); $my = & JFactory::getUser(); $row = new hwdvids_group( $db ); $row->load( $cid ); // fail if checked out not by 'me' if ($row->isCheckedOut( $my->id )) { //BUMP needs change for multilanguage support mosRedirect( 'index.php?option='.$option.'&task=categories', 'The categorie $row->catname is currently being edited by another administrator.' ); } $db->SetQuery("SELECT * FROM #__hwdvidsgroups" . "\nWHERE id = $cid"); $db->loadObject($row); if ($cid) { $row->checkout( $my->id ); } else { $row->published = 1; } $query = "SELECT m.*, u.name, u.username" . " FROM #__hwdvidsgroup_membership AS m" . " LEFT JOIN #__users AS u ON u.id = m.memberid" . " WHERE m.groupid = ".$row->id; $db->SetQuery($query); $groupMembers = $db->loadObjectList(); $query = "SELECT v.*, video.title" . " FROM #__hwdvidsvideos AS video" . " LEFT JOIN #__hwdvidsgroup_videos AS v ON v.videoid = video.id" . " WHERE v.groupid = ".$row->id; $db->SetQuery($query); $groupVideos = $db->loadObjectList(); hwdvids_HTML::editgroups($row, $groupMembers, $groupVideos); }
/** * start converter */ function startconverter() { global $limit, $limitstart; $db =& JFactory::getDBO(); $db->SetQuery( "SELECT count(*)" . "\nFROM #__hwdvidsvideos AS a" . "\nWHERE a.approved = \"queuedforconversion\"" ); $total1 = $db->loadResult(); echo $db->getErrorMsg(); $db->SetQuery( "SELECT count(*)" . "\nFROM #__hwdvidsvideos AS a" . "\nWHERE a.approved = \"queuedforthumbnail\"" ); $total2 = $db->loadResult(); echo $db->getErrorMsg(); $db->SetQuery( "SELECT count(*)" . "\nFROM #__hwdvidsvideos AS a" . "\nWHERE a.approved LIKE \"converting%\"" ); $total3 = $db->loadResult(); echo $db->getErrorMsg(); $db->SetQuery( "SELECT count(*)" . "\nFROM #__hwdvidsvideos AS a" . "\nWHERE a.approved = \"queuedforswf\"" ); $total4 = $db->loadResult(); echo $db->getErrorMsg(); $db->SetQuery( "SELECT count(*)" . "\nFROM #__hwdvidsvideos AS a" . "\nWHERE a.approved = \"queuedformp4\"" ); $total5 = $db->loadResult(); echo $db->getErrorMsg(); $db->SetQuery( "SELECT count(*)" . "\nFROM #__hwdvidsvideos AS a" . "\nWHERE a.approved = \"re-generate_thumb\"" ); $total6 = $db->loadResult(); echo $db->getErrorMsg(); $db->SetQuery( "SELECT count(*)" . "\nFROM #__hwdvidsvideos AS a" . "\nWHERE a.approved = \"re-calculate_duration\"" ); $total7 = $db->loadResult(); echo $db->getErrorMsg(); hwdvids_HTML::startconverter($total1, $total2, $total3, $total4, $total5, $total6, $total7); }
/** * backup tables */ function backuptables() { hwdvids_HTML::backuptables(); }