/** * List Groups Created by User */ function pending() { global $mainframe, $limitstart, $isModerator, $hwdvsItemid, $hwdvs_joinv, $hwdvs_selectv; $c = hwd_vs_Config::get_instance(); $db = & JFactory::getDBO(); $my = & JFactory::getUser(); if (!$isModerator) { $msg = "Only moderators can access this page"; $mainframe->enqueueMessage($msg); $mainframe->redirect( JURI::root( true ) . '/index.php?option=com_hwdvideoshare&task=frontpage&Itemid='.$hwdvsItemid ); } $limit = intval($c->vpp); $where = ' WHERE video.approved = "pending"'; $db->SetQuery( "SELECT count(*) FROM #__hwdvidsvideos AS video $hwdvs_joinv $where" ); $total = $db->loadResult(); jimport('joomla.html.pagination'); $pageNav = new JPagination( $total, $limitstart, $limit ); $query = 'SELECT'.$hwdvs_selectv . ' FROM #__hwdvidsvideos AS video' . $hwdvs_joinv . $where . ' ORDER BY video.date_uploaded DESC' ; $db->SetQuery($query, $pageNav->limitstart, $pageNav->limit); $rows = $db->loadObjectList(); hwd_vs_html::pending($rows, $pageNav, $total); }
/** * Featured groups */ function featuredGroups() { global $mainframe, $limitstart, $Itemid, $hwdvs_joing, $hwdvs_selectg; $db = & JFactory::getDBO(); $c = hwd_vs_Config::get_instance(); $limit = intval($c->gpp); $where = ' WHERE g.published = 1'; $where .= ' AND g.featured = 1'; $db->SetQuery( 'SELECT count(*)' . ' FROM #__hwdvidsgroups AS g' . $where ); $total = $db->loadResult(); echo $db->getErrorMsg(); jimport('joomla.html.pagination'); $pageNav = new JPagination( $total, $limitstart, $limit ); $query = 'SELECT'.$hwdvs_selectg . ' FROM #__hwdvidsgroups AS g' . $hwdvs_joing . $where . ' ORDER BY g.id DESC' ; $db->SetQuery($query, $pageNav->limitstart, $pageNav->limit); $rows = $db->loadObjectList(); hwd_vs_html::featuredGroups($rows, $pageNav, $total); }
/** * Query SQL for user inputted search pattern * * @return Nothing */ function displayResults() { global $mainframe, $smartyvs, $limitstart, $hwdvs_joinv, $hwdvs_joing, $hwdvs_selectv, $hwdvs_selectg; $c = hwd_vs_Config::get_instance(); $db = & JFactory::getDBO(); $my = & JFactory::getUser(); $pattern = JRequest::getVar( 'pattern', '' ); $category_id = JRequest::getInt( 'category_id', '0' ); $vpp = JRequest::getInt( 'rpp', '0' ); $gpp = JRequest::getInt( 'rpp', '0' ); $sort = JRequest::getInt( 'sort', '0' ); $ep = JRequest::getVar( 'ep', '' ); $ex = JRequest::getVar( 'ex', '' ); if (empty($vpp) || $vpp == 0) { $limitv = intval($c->vpp); } else { $limitv = $vpp; } if (empty($gpp) || $gpp == 0) { $limitg = intval($gpp); } else { $limitg = $gpp; } $smartyvs->assign("pattern", $pattern); $smartyvs->assign("ep", $ep); $smartyvs->assign("ex", $ex); $smartyvs->assign("rpp", $vpp); $smartyvs->assign("sort", $sort); require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'helpers'.DS.'search.php'); $whereVideos = hwd_vs_search::search_perform_videos(); $whereGroups = hwd_vs_search::search_perform_groups(); if ($sort == 1) { $orderVideos = " ORDER BY video.title ASC"; } else if ($sort == 2) { $orderVideos = " ORDER BY video.date_uploaded DESC"; } else if ($sort == 3) { $orderVideos = " ORDER BY video.updated_rating DESC"; } else if ($sort == 4) { $orderVideos = " ORDER BY video.number_of_views DESC"; } else { $orderVideos = ""; } $db->SetQuery( "SELECT count(*) FROM #__hwdvidsvideos AS video $whereVideos"); $totalVideos = $db->loadResult(); jimport('joomla.html.pagination'); $videoNav = new JPagination( $totalVideos, $limitstart, $limitv ); $query = "SELECT $hwdvs_selectv FROM #__hwdvidsvideos AS video $hwdvs_joinv $whereVideos $orderVideos"; //echo $query; $db->SetQuery($query, $videoNav->limitstart, $videoNav->limit); $matchingVideos = $db->loadObjectList(); if ($c->diable_nav_groups == 0) { // count matching groups $db->SetQuery("SELECT count(*) FROM #__hwdvidsgroups AS g $hwdvs_joing $whereGroups"); $totalGroups = $db->loadResult(); echo $db->getErrorMsg(); // pagination $groupNav = new JPagination( $totalGroups, $limitstart, $limitg ); // get matching group data $query = "SELECT $hwdvs_selectg FROM #__hwdvidsgroups AS g $hwdvs_joing $whereGroups"; $db->SetQuery($query, $groupNav->limitstart, $groupNav->limit); $matchingGroups = $db->loadObjectList(); } else { $totalGroups = 0; $groupNav = null; $matchingGroups = null; } // sent out hwd_vs_html::search($totalVideos, $matchingVideos, $videoNav, $totalGroups, $matchingGroups, $groupNav, $pattern, $category_id); }
/** * Outputs frontpage HTML * * @return Nothing */ function addConfirm($admin_import=false) { global $Itemid, $j15, $j16; $c = hwd_vs_Config::get_instance(); $db = & JFactory::getDBO(); $my = & JFactory::getUser(); $acl= & JFactory::getACL(); $security_code = JRequest::getCmd( 'security_code', '' ); if ($c->disablecaptcha == "1") { $checksecurity = "0"; } else { $checksecurity = "1"; } if ($checksecurity == "1" && !$admin_import) { if(($_SESSION['security_code'] == $security_code) && (!empty($_SESSION['security_code'])) ) { unset($_SESSION['security_code']); } else { hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ALERT_ERRSC, "exclamation.png", 0); return; } } $requestarray = JRequest::get( 'default', 2 ); $embeddump = $requestarray['embeddump']; $remote_verified = null; $parsedurl = parse_url($embeddump); if (empty($parsedurl['host'])) { $parsedurl['host'] = ''; } preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $parsedurl['host'], $regs); if (empty($regs['domain'])) { $regs['domain'] = ''; } if ($j15) { if ($regs['domain'] == 'youtube.com' && file_exists(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'youtube.php')) { require_once(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'youtube.php'); } else if ($regs['domain'] == 'google.com' && file_exists(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'google.php')) { require_once(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'google.php'); } else if (file_exists(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.$regs['domain'].'.php')) { require_once(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.$regs['domain'].'.php'); } else { require_once(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'youtube.php'); $regs['domain'] = 'remote'; } } if ($j16) { if ($regs['domain'] == 'youtube.com' && file_exists(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'youtube'.DS.'youtube.php')) { require_once(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'youtube'.DS.'youtube.php'); } else if ($regs['domain'] == 'google.com' && file_exists(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'google'.DS.'google.php')) { require_once(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'google'.DS.'google.php'); } else if (file_exists(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'thirdpartysupportpack'.DS.$regs['domain'].'.php')) { require_once(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'thirdpartysupportpack'.DS.$regs['domain'].'.php'); } else { require_once(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'remote'.DS.'remote.php'); $regs['domain'] = 'remote'; } } $failures = ""; if (!isset($remote_verified)) { $cn = 'hwd_vs_tp_'.preg_replace("/[^a-zA-Z0-9s_-]/", "", $regs['domain']); $f_processc = preg_replace("/[^a-zA-Z0-9s_-]/", "", $regs['domain']).'processCode'; $f_processi = preg_replace("/[^a-zA-Z0-9s_-]/", "", $regs['domain']).'processThumbnail'; $f_processt = preg_replace("/[^a-zA-Z0-9s_-]/", "", $regs['domain']).'processTitle'; $f_processd = preg_replace("/[^a-zA-Z0-9s_-]/", "", $regs['domain']).'processDescription'; $f_processk = preg_replace("/[^a-zA-Z0-9s_-]/", "", $regs['domain']).'processKeywords'; $f_processl = preg_replace("/[^a-zA-Z0-9s_-]/", "", $regs['domain']).'processDuration'; $tp = new $cn(); $ext_v_code = $tp->$f_processc($embeddump); //check if already exists $db->SetQuery( 'SELECT count(*) FROM #__hwdvidsvideos WHERE video_id = "'.$ext_v_code[1].'"' ); $duplicatecount = $db->loadResult(); if ($duplicatecount > 0 && $admin_import == false) { hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ALERT_DUPLICATE, "exclamation.png", 0); return; } else if ($duplicatecount > 0 && $admin_import == true) { return false; } $ext_v_title = $tp->$f_processt($embeddump, @$ext_v_code[1]); $ext_v_descr = $tp->$f_processd($embeddump, @$ext_v_code[1]); $ext_v_keywo = $tp->$f_processk($embeddump, @$ext_v_code[1]); $ext_v_durat = $tp->$f_processl($embeddump, @$ext_v_code[1]); if ($ext_v_code[0] == "0") { require_once(JPATH_SITE.'/plugins/hwdvs-thirdparty/remote.php'); $regs['domain'] = 'remote'; $tp = new hwd_vs_tp_remote(); $ext_v_code = $tp->remoteProcessCode($embeddump); $ext_v_title = $tp->remoteProcessTitle($embeddump, @$ext_v_code[1]); $ext_v_descr = $tp->remoteProcessDescription($embeddump, @$ext_v_code[1]); $ext_v_keywo = $tp->remoteProcessKeywords($embeddump, @$ext_v_code[1]); $ext_v_durat = $tp->remoteProcessDuration($embeddump, @$ext_v_code[1]); if ($ext_v_code[0] == "0") { hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_INFO_TPPROCESSFAIL, "exclamation.png", 0); return; } //check if already exists $db->SetQuery( 'SELECT count(*) FROM #__hwdvidsvideos WHERE video_id = "'.$ext_v_code[1].'"' ); $duplicatecount = $db->loadResult(); if ($duplicatecount > 0 && $admin_import == false) { hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ALERT_DUPLICATE, "exclamation.png", 0); return; } else if ($duplicatecount > 0 && $admin_import == true) { return false; } } if ($ext_v_title[0] == 0) {$failures.=_HWDVIDS_INFO_TPTITLEFAIL."<br />";} if ($ext_v_descr[0] == 0) {$failures.=_HWDVIDS_INFO_TPDESCFAIL."<br />";} if ($ext_v_keywo[0] == 0) {$failures.=_HWDVIDS_INFO_TPKWFAIL."<br />";} if ($ext_v_durat[0] == 0) {$failures.=_HWDVIDS_INFO_TPDRFAIL."<br />";} } else if ($remote_verified == 0) { $error_msg = _HWDVIDS_ERROR_UPLDERR11."<br /><br />"._HWDVIDS_INFO_SUPPTPW."<br />".hwd_vs_tools::generateSupportedWebsiteList(); hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, $error_msg, "exclamation.png", 1); return; } $title = hwd_vs_tools::generatePostTitle($ext_v_title[1]); $description = hwd_vs_tools::generatePostDescription($ext_v_descr[1]); $tags = hwd_vs_tools::generatePostTags($ext_v_keywo[1]); $category_id = JRequest::getInt( 'category_id', 0, 'post' ); $public_private = JRequest::getWord( 'public_private' ); $allow_comments = JRequest::getInt( 'allow_comments', 0, 'post' ); $allow_embedding = JRequest::getInt( 'allow_embedding', 0, 'post' ); $allow_ratings = JRequest::getInt( 'allow_ratings', 0, 'post' ); $checkform = hwd_vs_tools::checkFormComplete($title, $description, $category_id, $tags, $public_private, $allow_comments, $allow_embedding, $allow_ratings); if (!$checkform) { return; } $row = new hwdvids_video($db); $password = Jrequest::getVar( 'hwdvspassword', '' ); if (!empty($password)) { $password = md5($password); $_POST['password'] = $password; } $_POST['video_type'] = $regs['domain']; $_POST['video_id'] = $ext_v_code[1]; $_POST['title'] = $title; $_POST['description'] = $description; $_POST['category_id'] = $category_id; $_POST['tags'] = $tags; $_POST['public_private'] = $public_private; $_POST['allow_comments'] = $allow_comments; $_POST['allow_embedding'] = $allow_embedding; $_POST['allow_ratings'] = $allow_ratings; $_POST['video_length'] = $ext_v_durat[1]; $_POST['date_uploaded'] = date('Y-m-d H:i:s'); if ($admin_import) { $_POST['user_id'] = $_REQUEST['user_id']; } else { $_POST['user_id'] = $my->id; } if ($c->aa3v == 1) { $_POST['approved'] = "yes"; $_POST['published'] = "1"; } else { $_POST['approved'] = "pending"; $_POST['published'] = "0"; } // bind it to the table if (!$row->bind($_POST)) { echo "<script type=\"text/javascript\">alert('".$row->getError()."');window.history.go(-1);</script>\n"; exit(); } // store it in the db if (!$row->store()) { echo "<script type=\"text/javascript\">alert('".$row->getError()."');window.history.go(-1);</script>\n"; exit(); } include_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'helpers'.DS.'events.php'); $params->title = $title; $params->id = $row->id; $params->category_id = $row->category_id; $params->type = $row->video_type; $params->user_id = $row->user_id; hwdvsEvent::onAfterVideoUpload($params); // save remote thumbnail to disk $data = @explode(",", $row->video_id); $thumburl = hwd_vs_tools::get_final_url( @$ext_v_code[2] ); $thumbbase = "tp-".$row->id.".jpg"; $thumbpath = JPATH_SITE.DS."hwdvideos".DS."thumbs".DS.$thumbbase; $ch = curl_init ($thumburl); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_BINARYTRANSFER,1); $rawdata=curl_exec($ch); curl_close ($ch); if(file_exists($thumbpath)) { unlink($thumbpath); } $fp = fopen($thumbpath,'x'); fwrite($fp, $rawdata); fclose($fp); if(file_exists($thumbpath)) { $db->SetQuery( "UPDATE #__hwdvidsvideos SET `thumbnail` = \"$thumbbase\" WHERE id = $row->id" ); $db->Query(); } $video = new hwdvids_video($db); $video->load( $row->id ); if (!$admin_import) { hwd_vs_html::addConfirm($title, $failures, $video); } else { return true; } }
/** * Outputs frontpage HTML * * @return Nothing */ function viewPlaylist() { global $mainframe; $c = hwd_vs_Config::get_instance(); $db = & JFactory::getDBO(); $my = & JFactory::getUser(); $acl= & JFactory::getACL(); $usersConfig = &JComponentHelper::getParams( 'com_users' ); $playlist_id = JRequest::getInt( 'playlist_id', 0 ); $row = new hwdvids_playlist($db); $row->load( $playlist_id ); hwd_vs_html::viewPlaylist($row); }
/** * Outputs frontpage HTML * * @return Nothing */ function editGroup() { global $mosConfig_live_site, $mainframe, $Itemid; $c = hwd_vs_Config::get_instance(); $db = & JFactory::getDBO(); $my = & JFactory::getUser(); $acl= & JFactory::getACL(); if (!hwd_vs_access::checkAccess($c->gtree_grup, $c->gtree_grup_child, 4, 0, _HWDVIDS_TITLE_NOACCESS, _HWDVIDS_ALERT_REGISTERFORGRUP, _HWDVIDS_ALERT_GRUP_NOT_AUTHORIZED, "exclamation.png", 0, "core.frontend.group")) {return;} $groupid = JRequest::getInt( 'groupid', 0 ); $row = new hwdvids_group($db); $row->load( $groupid ); //check valid user if ($row->adminid != $my->id) { $mainframe->enqueueMessage(_HWDVIDS_ALERT_NOPERM); $mainframe->redirect( JURI::root() . 'index.php?option=com_hwdvideoshare&task=groups&Itemid='.$Itemid ); } //Videos that are approved(converted) and published in this group $query = 'SELECT user.*, mem.memberid' . ' FROM #__hwdvidsgroup_membership AS `mem`' . ' LEFT JOIN #__hwdvidsgroups AS `group` ON mem.groupid = group.id' . ' LEFT JOIN #__users AS `user` ON user.id = mem.memberid' . ' WHERE mem.groupid = '.$row->id ; $db->SetQuery($query); $grp_members = $db->loadObjectList(); echo $db->getErrorMsg(); hwd_vs_html::editGroupInfo($row, $grp_members); }
/** * Outputs frontpage HTML * * @return Nothing */ function editChannel() { global $mosConfig_live_site, $mainframe, $Itemid; $c = hwd_vs_Config::get_instance(); $db = & JFactory::getDBO(); $my = & JFactory::getUser(); $acl= & JFactory::getACL(); $channel_id = JRequest::getInt( 'channel_id', 0 ); $row = new hwdvids_channel($db); $row->load( $channel_id ); if ($row->user_id !== $my->id) { $mainframe->enqueueMessage("You do not have permission to edit this channel"); $mainframe->redirect( JRoute::_("index.php?option=com_hwdvideoshare&Itemid=$Itemid&task=channels") ); } hwd_vs_html::editChannelInfo($row); }