Esempio n. 1
0
	/**
	 *
	 *
	 *
	 */
	function checkAccess($gtree, $gtree_child, $nav, $usernav, $title, $message_register, $message_denied, $icon, $backlink, $action="core.frontend.access", $noMessage=0)
	{
		global $j15, $j16, $smartyvs;
        $c = hwd_vs_Config::get_instance();
		$my = & JFactory::getUser();
		$acl= & JFactory::getACL();
		$usersConfig = & JComponentHelper::getParams( 'com_users' );

		if ($j16)
		{
			// Access check.
			if (!JFactory::getUser()->authorise($action, 'com_hwdvideoshare'))
			{
				if ($noMessage == 1)
				{
					return false;
				}
				else
				{
					JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
					if ($my->id == 0)
					{
						$smartyvs->assign("showconnectionbox", 1);
					}
					hwd_vs_tools::infomessage($nav, $usernav, $title, $message_register, $icon, $backlink);
					return false;
				}
			}
		}
		else
		{
			if (!hwd_vs_access::allowAccess( $gtree, $gtree_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') ) ) )
				{
					if ($noMessage == 1)
					{
						return false;
					}
					else
					{
						if ($my->id == 0)
						{
							$smartyvs->assign("showconnectionbox", 1);
						}
						hwd_vs_tools::infomessage($nav, $usernav, $title, $message_register, $icon, $backlink);
						return false;
					}
				}
				else
				{
					if ($noMessage == 1)
					{
						return false;
					}
					else
					{
						if ($my->id == 0)
						{
							$smartyvs->assign("showconnectionbox", 1);
						}
						hwd_vs_tools::infomessage($nav, $usernav, $title, $message_denied, $icon, $backlink);
						return false;
					}
				}
			}
		}
		return true;
	}
Esempio n. 2
0
    /**
     * Outputs frontpage HTML
     *
     * @return       Nothing
     */
    function addVideoToGroup()
	{
	global $database, $my, $acl, $mosConfig_absolute_path, $mosConfig_mailfrom, $mosConfig_fromname, $mosConfig_live_site, $Itemid, $mosConfig_sitename;
		$db = & JFactory::getDBO();
		$c = hwd_vs_Config::get_instance();
		$url = $db->getEscaped( strip_tags( trim( strtolower( mosGetParam( $_POST, 'url' ) ) ) ) );

		if (!$my->id) {
			hwd_vs_tools::infomessage(1, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ALERT_LOG2AV2G, "exclamation.png", 1);
			return;
		}

		$userid = $my->id;
		$videoid = intval ( mosGetParam($_POST, 'videoid') );
		$groupid = intval ( mosGetParam($_POST, 'groupid') );
		$date = date('Y-m-d H:i:s');
		$published = 1;

		if ($groupid == 0) {
			hwd_vs_tools::infomessage(1, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ALERTSELGROUP, "exclamation.png", 1);
			return;
		}

		$where = ' WHERE a.videoid = '.$videoid;
		$where .= ' AND a.groupid = '.$groupid;

		$db->SetQuery( 'SELECT count(*)'
							. ' FROM #__hwdvidsgroup_videos AS a'
							. $where
							);
  		$total = $db->loadResult();

		if ( $total>0 ) {
			hwd_vs_tools::infomessage(1, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ALERT_ALREADYAV2G, "exclamation.png", 1);
			return;
		}

		$row = new hwdvids_groupvideo($database);

		$_POST['videoid'] = $videoid;
		$_POST['groupid'] = $groupid;
		$_POST['memberid'] = $userid;
		$_POST['date'] = $date;

		// bind it to the table
		if (!$row -> bind($_POST)) {
			echo "<script> alert('"
				.$row -> getError()
				."'); window.history.go(-1); </script>\n";
			exit();
		}

		// store it in the db
		if (!$row -> store()) {
			echo "<script> alert('"
				.$row -> getError()
				."'); window.history.go(-1); </script>\n";
			exit();
		}

		// perform maintenance
		require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'libraries'.DS.'maintenance_recount.class.php');
		hwd_vs_recount::recountVideosInGroup($groupid);

		hwd_vs_tools::infomessage(1, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ALERT_SUCAV2G, "exclamation.png", 1);
		return;
	}
Esempio n. 3
0
   /**
	* edit videos
	*/
	function updateVideoSource()
	{
		global $option;
  		$db =& JFactory::getDBO();
		$my = & JFactory::getUser();
		$app = & JFactory::getApplication();
		$c = hwd_vs_Config::get_instance();

		$video_type	= Jrequest::getVar( 'videotype', '0' );
		$video_id	= Jrequest::getVar( 'id', '0' );
		$updatedetails	= Jrequest::getVar( 'updatedetails', '0' );

		$admin_import = true;
		require_once(JPATH_SITE.DS.'components'.DS.'com_hwdvideoshare'.DS.'models'.DS.'uploads.php');

		$row = new hwdvids_video($db);
		$row->load( $video_id );

		if ($video_type == 1)
		{
			$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 ($regs['domain'] == 'youtube.com' && file_exists(JPATH_SITE.'/plugins/hwdvs-thirdparty/youtube.php')) {
				require_once(JPATH_SITE.'/plugins/hwdvs-thirdparty/youtube.php');
			} else if ($regs['domain'] == 'google.com' && file_exists(JPATH_SITE.'/plugins/hwdvs-thirdparty/google.php')) {
				require_once(JPATH_SITE.'/plugins/hwdvs-thirdparty/google.php');
			} else if (file_exists(JPATH_SITE.'/plugins/hwdvs-thirdparty/'.$regs['domain'].'.php')) {
				require_once(JPATH_SITE.'/plugins/hwdvs-thirdparty/'.$regs['domain'].'.php');
			} else {

				$pos_flv = strpos($embeddump, ".flv");

				if ($pos_flv === false) {
					$remote_verified = 0;
				} else {
					$pos_flv = $pos_flv+4;
					$datadump = substr($embeddump, 0, $pos_flv);
					$pos_http = mb_strrpos($datadump, "http://");
					if ($pos_http === false) {
						$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;
					} else {
						$url = substr($datadump, $pos_http);
					}

					$pru = parse_url($url);
					$remoteurl = $pru['scheme']."://".$pru['host'].$pru['path'];

					if(!preg_match("/^[a-zA-Z]+[:\/\/]+[A-Za-z0-9\-_]+\\.+[A-Za-z0-9\.\/%&=\?\-_]+$/i",$remoteurl)) {
						$remote_verified = 0;
					} else {
						$filegrab = @file_get_contents($remoteurl, null, null, 0, 16);
						$filecheck = @strpos($remoteurl, "flv");
						if (isset($remoteurl) && !empty($remoteurl) && $filecheck !== false) {
							$remote_verified = 1;
						} else {
							$remote_verified = 0;
						}
					}
				}

			}

			$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_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);
				$ext_v_title = $tp->$f_processt($embeddump, @$ext_v_code[2]);
				$ext_v_descr = $tp->$f_processd($embeddump, @$ext_v_code[2]);
				$ext_v_keywo = $tp->$f_processk($embeddump, @$ext_v_code[2]);
				$ext_v_durat = $tp->$f_processl($embeddump, @$ext_v_code[2]);

				if ($ext_v_code[0] == "0") {
					hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_INFO_TPPROCESSFAIL, "exclamation.png", 0);
					return;
				}

				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;
			} else if ($remote_verified == 1) {
				$ext_v_code[1] = $remoteurl.",";
				$ext_v_title[1] = _HWDVIDS_UNKNOWN;
				$ext_v_descr[1] = _HWDVIDS_UNKNOWN;
				$ext_v_keywo[1] = _HWDVIDS_UNKNOWN;
				$ext_v_durat[1] = "0:00:00";
				$regs['domain'] = "remote";
			}

			//check if already exists
			$db->SetQuery( 'SELECT count(*) FROM #__hwdvidsvideos WHERE video_id = "'.$ext_v_code[1].'"' );
			$duplicatecount = $db->loadResult();

			$admin_import = false;

			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;
			}

			$title = $ext_v_title[1];
			$title = stripslashes($title);
			$title = stripslashes($title);
			$title = hwdEncoding::charset_decode_utf_8($title);
			$title = hwdEncoding::charset_encode_utf_8($title);
			$title = htmlspecialchars_decode($title);
			$title = addslashes($title);

			$description = $ext_v_descr[1];
			$description = stripslashes($description);
			$description = stripslashes($description);
			$description = hwdEncoding::charset_decode_utf_8($description);
			$description = hwdEncoding::charset_encode_utf_8($description);
			$description = htmlspecialchars_decode($description);
			$description = addslashes($description);

			$raw_tags = $ext_v_keywo[1];
			$tags = '';
			$tag_arr_co = explode(",", $raw_tags);

			for ($j=0, $m=count($tag_arr_co); $j < $m; $j++) {

				$row_co = $tag_arr_co[$j];
				$tag_arr_sp = explode(" ", $row_co);

				for ($k=0, $p=count($tag_arr_sp); $k < $p; $k++) {

					$row_sp = $tag_arr_sp[$k];
					$row_sp = hwdEncoding::charset_decode_utf_8($row_sp);
					$row_sp = preg_replace("/[^a-zA-Z0-9s_&#;-]/", "", $row_sp);
					$row_sp = hwdEncoding::charset_encode_utf_8($row_sp);

					if (!empty($row_sp)) {
						$tags.= $row_sp.",";
					}

				}
			}
			if (substr($tags, -2) == ", ") {$tags = substr($tags, 0, -2);}

			if (empty($title)) { $title = _HWDVIDS_UNKNOWN;}
			if (empty($description)) { $description = _HWDVIDS_UNKNOWN;}
			if (empty($tags)) { $tags = _HWDVIDS_UNKNOWN;}

			$_POST['video_type'] 		= $regs['domain'];
			$_POST['video_id'] 			= $ext_v_code[1];

			if ($updatedetails == "on") {
				$_POST['title'] 			= $ext_v_title[1];
				$_POST['description'] 		= $ext_v_descr[1];
				$_POST['tags'] 				= $ext_v_keywo[1];
			}

			// bind it to the table
			if (!$row -> bind($_POST)) {
				echo "<script> alert('"
					.$row -> getError()
					."'); window.history.go(-1); </script>\n";
				exit();
			}

			// store it in the db
			if (!$row -> store()) {
				echo "<script> alert('"
					.$row -> getError()
					."'); window.history.go(-1); </script>\n";
				exit();
			}

			$row->checkin();

		}
		else if ($video_type == 2)
		{
			$data = explode(",", $row->video_id);
			$thumbnail = @$data[1];

			$requestarray = JRequest::get( 'default', 2 );
			$videourl = $requestarray['embeddump'];

			$validated_video_url = hwd_vs_tools::validateUrl($videourl);

			if (empty($validated_video_url))
			{
				$msg = _HWDVIDS_ALERT_VURLWRONG;
				$app->enqueueMessage($msg);
				$app->redirect(JURI::root( true )."/administrator/index.php?option=com_hwdvideoshare&task=editvidsA&hidemainmenu=1&cid=".$row->id);
			}

			$new_video_id = $validated_video_url.",".$thumbnail;

			$_POST['video_type'] 		= "remote";
			$_POST['video_id'] 			= $new_video_id;
			if (empty($row->thumbnail) && !empty($thumbnail))
			{
				$_POST['thumbnail'] 	= $thumbnail;
			}

			// 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();
			}
			$row->checkin();
		}
		else if ($video_type == 3)
		{
			$data = explode(",", $row->video_id);
			$thumbnail = @$data[1];

			$requestarray = JRequest::get( 'default', 2 );
			$rtmpurl = $requestarray['embeddump'];
			$validated_rtmpurl = hwd_vs_tools::validateUrl($rtmpurl);

			if (empty($validated_rtmpurl))
			{
				$msg = _HWDVIDS_ALERT_VURLWRONG;
				$app->enqueueMessage($msg);
				$app->redirect(JURI::root( true )."/administrator/index.php?option=com_hwdvideoshare&task=editvidsA&hidemainmenu=1&cid=".$row->id);
			}

			$new_video_id = $validated_rtmpurl;

			$_POST['video_type'] 		= "rtmp";
			$_POST['video_id'] 			= $new_video_id;
			if (empty($row->thumbnail) && !empty($thumbnail))
			{
				$_POST['thumbnail'] 	= $thumbnail;
			}

			// 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();
			}
			$row->checkin();
		}

		require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'libraries'.DS.'maintenance_recount.class.php');
		hwd_vs_recount::recountVideosInCategory($row->category_id);

		$app->enqueueMessage(_HWDVIDS_ALERT_VIDSAVED);
		$app->redirect( JURI::root( true ) . '/administrator/index.php?option='.$option.'&task=editvidsA&hidemainmenu=1&cid='.$row->id );
	}
Esempio n. 4
0
    /**
     *
     */
    function viewPlaylist($row)
    {
    	global $mainframe, $Itemid, $smartyvs, $Itemid;
        $c = hwd_vs_Config::get_instance();

		// load the menu name
		jimport( 'joomla.application.menu' );
		$menu   = &JMenu::getInstance('site');
		$mparams = &$menu->getParams($Itemid);
		$mparams_pt	= $mparams->get( 'page_title', '');

		jimport( 'joomla.document.document' );
		$doc = & JFactory::getDocument();

		$active = &$menu->getActive();

		if (!empty($mparams_pt)) {
			$metatitle = $mparams_pt;
		} else if (!empty($active->name)) {
			$metatitle = $active->name;
		} else {
			$metatitle = _HWDVIDS_META_DEFAULT;
		}

        // decode
        $meta_title = html_entity_decode($row->playlist_name);
        // set the page/meta title
        $doc->setTitle( $metatitle." - "._HWDVIDS_META_EPL." - ".$meta_title );
        $doc->setMetaData( 'title' , $metatitle." - "._HWDVIDS_META_EPL." - ".$meta_title );
		hwd_vs_tools::generateActiveLink(1);
		hwd_vs_javascript::confirmdelete();
		hwd_vs_tools::generateBreadcrumbs();

		$smartyvs->assign("playlist_name", stripslashes($row->playlist_name));
		$smartyvs->assign("playlist_description", stripslashes($row->playlist_description));
		$smartyvs->assign("playlist_id", $row->id);

		$hwdvids_params['playlist']		= "pl_$row->id";
		$hwdvids_params['single_id']	= 0;
		$hwdvids_params['width'] 		= 320;
		$hwdvids_params['height'] 		= 240;
		$hwdvids_params['autostart'] 	= 1;
		$hwdvids_params['extended'] 	= 1;
		$hwdvids_params['showdetails'] 	= 1;
		$hwdvids_params['novtd'] 		= 10;

		$hwdvids_params['thumb_width'] 		= 60;
		$hwdvids_params['mod_hwd_itemid'] 	= 0;
		$hwdvids_params['trunc_title'] 		= '';
		$hwdvids_params['trunc_descr'] 		= '';
		$hwdvids_params['showtt'] 		    = '0';

		if ($hwdvids_params['mod_hwd_itemid'] == 0) {
			$hwdvids_params['mod_hwd_itemid'] = hwd_vs_tools::generateValidItemid();
		}

		require_once(JPATH_SITE.DS.'components'.DS.'com_hwdvideoshare'.DS.'xml'.DS.'xmlparse.class.php');
		$parser = new HWDVS_xmlParse();
		$parsed_list = $parser->parse($hwdvids_params['playlist']);

		if (count($parsed_list) > 0)
		{
			$smartyvs->assign("vid", $parsed_list[0]['id']);

			$row->video_id = "";
			$row->video_type = "playlist";
			$row->playlist = JURI::base( true )."/components/com_hwdvideoshare/xml/xspf/".$hwdvids_params['playlist'].".xml";
			$video_player = hwd_vs_tools::generateVideoPlayer( $row, $hwdvids_params['width'], $hwdvids_params['height'], $hwdvids_params['autostart'] );

			if ($hwdvids_params['extended'] == 1)
			{
				$tooltip = 1;
				$list = hwd_vs_tools::generateVideoListFromXml($parsed_list, $hwdvids_params['thumb_width'], $hwdvids_params['mod_hwd_itemid'], $tooltip, $hwdvids_params['trunc_title'], $hwdvids_params['trunc_descr'], "hwdvs_insert_playlist_video");
				$smartyvs->assign("list", $list);
			}
		}
		else
		{
			hwd_vs_tools::infomessage(4, 0, "Empty playlist", "This playlist does not contactin any videos", "exclamation.png", 0);
			return;
		}

if ($hwdvids_params['extended'] == 1) {

	if ($hwdvids_params['showdetails'] == 1)
	{
		$showdetails = '&showdetails=1';
		$div_height = $hwdvids_params['height']+70;
	}
	else
	{
		$showdetails = '&showdetails=0';
		$div_height = $hwdvids_params['height']+70;
	}

	$showdetails.= '&width='.$hwdvids_params['width'].'&height='.$hwdvids_params['height'];

	$random = rand();
	$smartyvs->assign("print_extended", 1);
	$smartyvs->assign("random", $random);

	$hwdvs_ajax_video_js = "<script language=\"javascript\" type=\"text/javascript\">
			<!--
			//Browser Support Code
			function hwdvs_insert_playlist_video(video_id){

				var ajaxRequest;  // The variable that makes Ajax possible!

				document.getElementById('hwdvs_player_container".$random."').style.padding = \"0\";
				document.getElementById('hwdvs_player_container".$random."').style.margin = \"0\";
				document.getElementById('hwdvs_player_container".$random."').style.height = \"".$div_height."px\";
				document.getElementById('hwdvs_player_container".$random."').innerHTML = '<div style=\"padding:5px;\">Loading...<br /><img src=\"".JURI::root( true )."/plugins/community/hwdvideoshare/loading.gif\"></div>';

				try{
					// Opera 8.0+, Firefox, Safari
					ajaxRequest = new XMLHttpRequest();
				} catch (e){
					// Internet Explorer Browsers
					try{
						ajaxRequest = new ActiveXObject(\"Msxml2.XMLHTTP\");
					} catch (e) {
						try{
							ajaxRequest = new ActiveXObject(\"Microsoft.XMLHTTP\");
						} catch (e){
							// Something went wrong
							alert(\"Your browser broke!\");
							return false;
						}
					}
				}
				// Create a function that will receive data sent from the server
				ajaxRequest.onreadystatechange = function(){
					if(ajaxRequest.readyState == 4){
						document.getElementById('hwdvs_player_container".$random."').style.padding = \"0\";
						document.getElementById('hwdvs_player_container".$random."').style.margin = \"0\";
						document.getElementById('hwdvs_player_container".$random."').innerHTML = ajaxRequest.responseText;

						var theInnerHTML = ajaxRequest.responseText;
						var theID = 'hwdvs_player_container".$random."';
						setAndExecute(theID,theInnerHTML);
						var containerHeight = document.getElementById('hwdvs_player_container".$random."').offsetHeight;
						var calcHeight = containerHeight-40;
						document.getElementById('videoDetails').style.height = calcHeight+\"px\";
						document.getElementById('videoDetails').style.overflow = \"auto\";
					}
				}
				ajaxRequest.open(\"GET\", \"".JURI::root( true )."/index.php?option=com_hwdvideoshare&task=grabajaxplayer&Itemid=".$hwdvids_params['mod_hwd_itemid'].$showdetails."&template=mod_hwd_vs_video_playlist_container&tmpl=component&video_id=\" + video_id, true);
				ajaxRequest.send(null);

				function setAndExecute(divId, innerHTML)
				{
					var div = document.getElementById(divId);
					div.innerHTML = innerHTML;
					var x = div.getElementsByTagName(\"script\");
					for(var i=0;i<x.length;i++)
					{
						eval(x[i].text);
					}
				}
			}

			//-->
		 </script>";
	$doc->addCustomTag($hwdvs_ajax_video_js);
}

		$smartyvs->assign("hwdvids_params", $hwdvids_params);
		$smartyvs->assign("video_player", $video_player);
		$smartyvs->display('playlist_view.tpl');

		return;
    }
Esempio n. 5
0
    /**
     * 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;
	}
Esempio n. 6
0
    /**
     * Query SQL for requested category data
     *
     * @return       Nothing
     */
    function viewcategory()
    {
        global $mainframe, $limitstart, $hwdvs_joinv, $hwdvs_selectv, $smartyvs;
		$c = hwd_vs_Config::get_instance();
		$db = & JFactory::getDBO();
		$my = & JFactory::getUser();
		$acl= & JFactory::getACL();
		$usersConfig = &JComponentHelper::getParams( 'com_users' );
		$app = & JFactory::getApplication();

        // number of videos to display
        $limit     = intval($c->vpp);

        // get POST array values
        $cat_id = JRequest::getInt( 'cat_id', 0 );

        // get category name
        $query_cat = 'SELECT *'
                   . ' FROM #__hwdvidscategories'
                   . ' WHERE id = '.$cat_id
                   ;
        $db->SetQuery( $query_cat );
        $cat = $db->loadObject();

		if (count($cat) == 0)
		{
			hwd_vs_tools::infomessage(1, 0,  _HWDVIDS_TITLE_NOACCESS, _HWDVIDS_TCDNE, "exclamation.png", 0);
			return;
		}

		$order = JRequest::getCmd( 'order' );
		$app->setUserState( 'hwdvsCategoryVideoOrder', $order );
		$filter_order = $app->getUserStateFromRequest( 'hwdvsCategoryVideoOrder', 'order' );

		if (!empty($filter_order)) {
			$cco = $filter_order;
		} else if ($cat->order_by !== "0") {
        	$cco = $cat->order_by;
        } else {
        	$cco = $c->cvordering;
        }

        // filter for sql data
        $where = ' WHERE video.published = 1';
        $where .= ' AND video.approved = "yes"';
        if ($c->countcvids == 1) {
	        $cids = hwd_vs_tools::getChildCategories($cat->id);
			$where .= ' AND video.category_id IN ('.$cids.')';
		} else {
        	$where .= ' AND video.category_id = '.$cat_id;
		}

		if ( $cco == "orderASC" ) {
			$order = ' ORDER BY video.ordering ASC';
		} else if ( $cco == "orderDESC" ) {
			$order = ' ORDER BY video.ordering DESC';
		} else if ( $cco == "dateASC" ) {
			$order = ' ORDER BY video.date_uploaded ASC';
		} else if ( $cco == "dateDESC" ) {
			$order = ' ORDER BY video.date_uploaded DESC';
		} else if ( $cco == "nameASC" ) {
			$order = ' ORDER BY video.title ASC';
		} else if ( $cco == "nameDESC" ) {
			$order = ' ORDER BY video.title DESC';
		} else if ( $cco == "hitsASC" ) {
			$order = ' ORDER BY video.number_of_views ASC';
		} else if ( $cco == "hitsDESC" ) {
			$order = ' ORDER BY video.number_of_views DESC';
		} else if ( $cco == "voteASC" ) {
			$order = ' ORDER BY video.updated_rating ASC';
		} else if ( $cco == "voteDESC" ) {
			$order = ' ORDER BY video.updated_rating DESC';
		} else if ( $cco == "random" ) {
			$order = ' ORDER BY rand()';
		} else {
			$order = ' ORDER BY video.date_uploaded DESC';
		}

        // count filtered videos
        $db->SetQuery( 'SELECT count(*)'
                     . ' FROM #__hwdvidsvideos AS video'
                     . $where
                     );
        $total = $db->loadResult();
        echo $db->getErrorMsg();

		jimport('joomla.html.pagination');
		$pageNav = new JPagination( $total, $limitstart, $limit );

        // get filtered video data
        $query = 'SELECT'.$hwdvs_selectv
                . ' FROM #__hwdvidsvideos AS video'
				. $hwdvs_joinv
                . $where
                . $order
                ;
        $db->SetQuery($query, $pageNav->limitstart, $pageNav->limit);
        $rows = $db->loadObjectList();

		if ($c->bviic == 1)
		{
			if (!hwd_vs_access::allowAccess( $cat->access_v, $cat->access_v_r, 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(2, 0, _HWDVIDS_TITLE_NOACCESS, _HWDVIDS_ALERT_REGISTERFORCAT, "exclamation.png", 0);
					return;
				} else {
					$smartyvs->assign("showconnectionbox", 1);
					hwd_vs_tools::infomessage(2, 0, _HWDVIDS_TITLE_NOACCESS, _HWDVIDS_ALERT_CAT_NOT_AUTHORIZED, "exclamation.png", 0);
					return;
				}
			}
		}

		// get subcategories
		$order = JRequest::getCmd( 'hwdcorder' );
		$app->setUserState( 'hwdvsCategoryOrder', $order );
		$filter_order = $app->getUserStateFromRequest( 'hwdvsCategoryOrder', 'cateorder' );

		if (!empty($filter_order)) {
			$c->cordering = $filter_order;
		}

		if ( $c->cordering == "orderASC" ) {
			$order = ' ORDER BY ordering ASC, category_name';
		} else if ( $c->cordering == "orderDESC" ) {
			$order = ' ORDER BY ordering DESC, category_name';
		} else if ( $c->cordering == "nameASC" ) {
			$order = ' ORDER BY category_name ASC';
		} else if ( $c->cordering == "nameDESC" ) {
			$order = ' ORDER BY category_name DESC';
		} else if ( $c->cordering == "novidsASC" ) {
			$order = ' ORDER BY num_vids ASC';
		} else if ( $c->cordering == "novidsDESC" ) {
			$order = ' ORDER BY num_vids DESC';
		} else if ( $c->cordering == "nosubsASC" ) {
			$order = ' ORDER BY num_subcats ASC';
		} else if ( $c->cordering == "nosubsDESC" ) {
			$order = ' ORDER BY num_subcats DESC';
		} else {
			$order = ' ORDER BY ordering, category_name';
		}

		$wherecat = ' WHERE published = 1 AND parent = '.$cat_id;
		if ($c->cat_he == 1) {
			$wherecat.= ' AND num_vids > 0';
		}

		$query = 'SELECT *'
				. ' FROM #__hwdvidscategories'
				. $wherecat
				. $order
				;
		$db->setQuery( $query );
		$subcats = $db->loadObjectList();

        // sent out
        hwd_vs_html::viewCategory($rows, $pageNav, $total, $cat_id, $cat, $subcats);
    }
Esempio n. 7
0
    /**
     * 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;
		}
	}
Esempio n. 8
0
    /**
     * Outputs frontpage HTML
     *
     * @return       Nothing
     */
    function savePlaylist()
	{
		global $mainframe, $params, $Itemid, $mosConfig_absolute_path, $mosConfig_mailfrom, $mosConfig_fromname, $mosConfig_live_site, $mosConfig_sitename;
		$c = hwd_vs_Config::get_instance();
		$db = & JFactory::getDBO();
		$my = & JFactory::getUser();
		$acl= & JFactory::getACL();

		if ($c->disablecaptcha == "0") {
			$sessid = session_id();
			if (empty($sessid)) {
				session_start();
			}
			if(($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSION['security_code'])) ) {
				// Insert you code for processing the form here, e.g emailing the submission, entering it into a database.
   		    	hwd_vs_playlists::bindNewPlaylist();
				unset($_SESSION['security_code']);
			} else {
				// Insert your code for showing an error message here
        		hwd_vs_tools::infomessage(3, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ALERT_ERRSC, "exclamation.png", 0);
				return;
			}

   		} else {
   		    hwd_vs_playlists::bindNewPlaylist();
		}
	}
Esempio n. 9
0
    /**
     * Outputs frontpage HTML
     *
     * @return       Nothing
     */
    function savegroup()
	{
		global $mainframe, $params, $Itemid, $mosConfig_absolute_path, $mosConfig_mailfrom, $mosConfig_fromname, $mosConfig_live_site, $mosConfig_sitename;
		$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;}

		if ($c->disablecaptcha == "0") {
			$sessid = session_id();
			if (empty($sessid)) {
				session_start();
			}
			if(($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSION['security_code'])) ) {
				// Insert you code for processing the form here, e.g emailing the submission, entering it into a database.
   		    	hwd_vs_groups::bindNewGroup();
				unset($_SESSION['security_code']);
			} else {
				// Insert your code for showing an error message here
        		hwd_vs_tools::infomessage(3, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ALERT_ERRSC, "exclamation.png", 0);
				return;
			}

   		} else {
   		    hwd_vs_groups::bindNewGroup();
		}
	}
Esempio n. 10
0
    /**
     * Generates the array of information for a standard group member list
     *
     * @param array  $rows  the list from a standard sql queries
     * @return       $code  the array prepared for Smarty template
     */
    function validateVideoAccess($row, $message=true)
    {
		global $mainframe, $hwdvsItemid, $smartyvs, $isModerator;
		$c = hwd_vs_Config::get_instance();
  		$db =& JFactory::getDBO();
		$my = & JFactory::getUser();

        if (count($row) < 1)
        {
        	hwd_vs_tools::infomessage(1, 0, _HWDVIDS_TITLE_NOACCESS, _HWDVIDS_ALERT_VIDNOEXIST, "exclamation.png", 0);
			return false;
        }

        if (!$isModerator && $row->published !== "1")
        {
        	hwd_vs_tools::infomessage(1, 0, _HWDVIDS_TITLE_NOACCESS, "This video is not published", "exclamation.png", 0);
			return false;
        }

        if ($row->approved == "deleted")
        {
        	hwd_vs_tools::infomessage(1, 0, _HWDVIDS_TITLE_NOACCESS, "This video has been deleted", "exclamation.png", 0);
			return false;
        }

        if (!$isModerator && $row->approved == "pending")
        {
        	hwd_vs_tools::infomessage(1, 0, _HWDVIDS_TITLE_NOACCESS, "This video is pending approval", "exclamation.png", 0);
			return false;
        }

        if (preg_match("/queued/i", $row->approved))
        {
        	hwd_vs_tools::infomessage(1, 0, _HWDVIDS_TITLE_NOACCESS, "This video is queued for video conversion", "exclamation.png", 0);
			return false;
        }

        if (preg_match("/converting/i", $row->approved))
        {
        	hwd_vs_tools::infomessage(1, 0, _HWDVIDS_TITLE_NOACCESS, "This video is currently being processed", "exclamation.png", 0);
			return false;
        }

        if ($isModerator && $row->approved == "pending")
        {
        	// OK
        }
        else if ($row->approved !== "yes")
        {
        	hwd_vs_tools::infomessage(1, 0, _HWDVIDS_TITLE_NOACCESS, "This video is not approved", "exclamation.png", 0);
			return false;
        }

        if ( $row->public_private == "registered" && $my->id == 0 )
        {
        	if ($message)
        	{
					if (!$my->id)
					{
						$smartyvs->assign("showconnectionbox", 1);
					}
					hwd_vs_tools::infomessage(1, 0, _HWDVIDS_TITLE_NOACCESS, _HWDVIDS_ORUCAV, "exclamation.png", 0);
        	}
			return false;
        }

        if ( $row->public_private == "me" && $my->id !== $row->user_id )
        {
        	if ($message)
        	{
					if (!$my->id)
					{
						$smartyvs->assign("showconnectionbox", 1);
					}
					hwd_vs_tools::infomessage(1, 0, _HWDVIDS_TITLE_NOACCESS, _HWDVIDS_OOCAV, "exclamation.png", 0);
        	}
			return false;
        }

        if ( $row->public_private == "password" )
        {
			$password = Jrequest::getVar( 'password', '' );
			$pass_check_variable = $mainframe->getUserState( "hwdvs_pw_$row->id", "notset" );
			$link = JRoute::_("index.php?option=com_hwdvideoshare&task=viewvideo&Itemid=$hwdvsItemid&video_id=".$row->id);

			if ($pass_check_variable == "notset")
			{
				if (!empty($password))
				{
					if (md5($password) == $row->password)
					{
						$mainframe->setUserState( "hwdvs_pw_$row->id", $password );
					}
					else
					{
						return false;
					}
				}
				else
				{
					if ($message)
					{
						$message = '<p>'._HWDVIDS_TVPP.'</p><br /><form action="'.$link.'" method="post">
						'._HWDVIDS_PASSWORD.'&nbsp;&nbsp;<input name="password" value="" type="password" class="inputbox" size="20" maxlength="500" style="width: 200px;" />
						<input type="submit" value="'._HWDVIDS_BUTTON_VIEW.'">
						</form>';

						hwd_vs_tools::infomessage(1, 0, _HWDVIDS_TITLE_NOACCESS, $message, null, 0);
					}
        			return false;
				}
			}
			else
			{
				if (md5($password) == $row->password)
				{
					$mainframe->setUserState( "hwdvs_pw_$row->id", $password );
				}
				else
				{
					if ($message)
					{
						$message = '<p>'._HWDVIDS_IPW.'</p><br /><form action="'.$link.'" method="post">
						'._HWDVIDS_PASSWORD.'&nbsp;&nbsp;<input name="password" value="" type="password" class="inputbox" size="20" maxlength="500" style="width: 200px;" />
						<input type="submit" value="'._HWDVIDS_BUTTON_VIEW.'">
						</form>';

						hwd_vs_tools::infomessage(1, 0, _HWDVIDS_TITLE_NOACCESS, $message, null, 0);
					}
					return false;
				}
			}
        }

        if ( $row->public_private == "group" )
        {
			if (!hwd_vs_access::allowAccess( $row->password, 'RECURSE', hwd_vs_access::userGID( $my->id )))
			{
				if ($message)
				{
					if (!$my->id)
					{
						$smartyvs->assign("showconnectionbox", 1);
					}
					hwd_vs_tools::infomessage(1, 0, _HWDVIDS_TITLE_NOACCESS, "You do not have permission to view this video, you do not have the necessary access group.", "exclamation.png", 1);
				}
				return false;
			}
        }

        if ( $row->public_private == "level" )
        {
			if (!hwd_vs_access::allowLevelAccess( $row->password, $my->get('aid', 0)))
			{
				if ($message)
				{
					if (!$my->id)
					{
						$smartyvs->assign("showconnectionbox", 1);
					}
					hwd_vs_tools::infomessage(2, 0,  _HWDVIDS_TITLE_NOACCESS, "You do not have permission to view this video, you do not how the necessary access level.", "exclamation.png", 0);
				}
				return false;
			}
        }

		if ($row->category_id !== "0")
		{
			$usersConfig = &JComponentHelper::getParams( 'com_users' );
			$acl= & JFactory::getACL();

			$query = "SELECT access_v, access_v_r FROM #__hwdvidscategories WHERE id = $row->category_id";
			$db->SetQuery($query);
			$category = $db->loadObject();

        	if (isset($category))
        	{
				if (!hwd_vs_access::allowAccess( $category->access_v, $category->access_v_r, hwd_vs_access::userGID( $my->id )))
				{
					if ( ($my->id < 1) && (!$usersConfig->get( 'allowUserRegistration' ) == '0' && hwd_vs_access::allowAccess( $category->access_v, 'RECURSE', $acl->get_group_id('Registered','ARO') ) ) )
					{
						if ($message)
						{
							if (!$my->id)
							{
								$smartyvs->assign("showconnectionbox", 1);
							}
							hwd_vs_tools::infomessage(2, 0, _HWDVIDS_TITLE_NOACCESS, _HWDVIDS_ALERT_REGISTERFORVCAT, "exclamation.png", 0);
						}
						return false;
					}
					else
					{
						if ($message)
						{
							if (!$my->id)
							{
								$smartyvs->assign("showconnectionbox", 1);
							}
							hwd_vs_tools::infomessage(2, 0, _HWDVIDS_TITLE_NOACCESS, _HWDVIDS_ALERT_VCAT_NOT_AUTHORIZED, "exclamation.png", 0);
						}
						return false;
					}
				}
			}
		}
		return true;
    }
Esempio n. 11
0
    /**
     * Outputs frontpage HTML
     *
     * @return       Nothing
     */
	function viewChannel()
	{
		global $smartyvs, $mainframe, $mosConfig_live_site, $limitstart, $Itemid, $hwdvs_joinv, $hwdvs_selectv, $hwdvs_joing, $hwdvs_selectg;
		$c = hwd_vs_Config::get_instance();
		$db = & JFactory::getDBO();
		$my = & JFactory::getUser();
		$acl= & JFactory::getACL();
		$usersConfig = &JComponentHelper::getParams( 'com_users' );

		$user_id = JRequest::getInt( 'user_id', 0, 'request' );
		$sort = JRequest::getWord( 'sort', 'none', 'request' );

		$db->SetQuery( 'SELECT count(*) FROM #__hwdvidschannels WHERE user_id = '.$user_id );
  		$channel_exists = $db->loadResult();

		if ( $channel_exists == 0 && $user_id == $my->id && $sort == "none" )
		{
			$mainframe->redirect( JURI::root() . 'index.php?option=com_hwdvideoshare&task=createChannel&Itemid='.$Itemid );
		}

		if ( $channel_exists == 0)
		{
			$db->SetQuery( 'SELECT username FROM #__users WHERE id = '.$user_id );
			$username = $db->loadResult();

			if (!isset($username) || empty($username))
			{
				$smartyvs->assign("showconnectionbox", 0);
				hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_NOACCESS, "This channel does not exist", "exclamation.png", 0);
				return;
			}

			$smartyvs->assign("channelExists", null);
			$channel->user_id = $user_id;
		}
		else
		{
			$smartyvs->assign("channelExists", 1);

			$query = 'SELECT * FROM #__hwdvidschannels WHERE user_id = '.$user_id;
			$db->SetQuery($query);
			$channel = $db->loadObject();

			$channel->views++;
			$db->SetQuery("UPDATE #__hwdvidschannels SET views = $channel->views WHERE id = $channel->id");
			$db->Query();

			$query = 'SELECT registerDate, lastvisitDate FROM #__users WHERE id = '.$channel->user_id;
			$db->SetQuery($query);
			$channelUser = $db->loadObject();

			$channel->registerDate = $channelUser->registerDate;
			$channel->lastvisitDate = $channelUser->lastvisitDate;

			$query = 'SELECT count(*) FROM #__hwdvidssubs WHERE memberid = '.$channel->user_id;
			$db->SetQuery($query);
			$channel->subscribers = $db->loadResult();

			$query = 'SELECT count(*) FROM #__hwdvidsvideos WHERE user_id = '.$channel->user_id;
			$db->SetQuery($query);
			$channel->uploads = $db->loadResult();

			if ($c->cbavatar == "2" && $c->cbint !== "5")
			{
				$channel->thumbnail = hwd_vs_tools::generateAvatar($channel->user_id, null, 0);
			}
			else
			{
				if (file_exists(JPATH_SITE.DS."hwdvideos".DS."thumbs".DS.$channel->channel_thumbnail))
				{
					$channel->thumbnail = JURI::root()."hwdvideos/thumbs/".$channel->channel_thumbnail;
				}
				else
				{
					$channel->thumbnail = null;
				}
			}
		}

		jimport('joomla.html.pagination');
		switch ($sort)
		{
			case "uploads":
			case "none":

				$limit     = intval($c->vpp);

				$where = ' WHERE video.published = 1';
				$where .= ' AND video.approved = "yes"';
				$where .= ' AND video.user_id = '.$channel->user_id;

				$db->SetQuery( "SELECT count(*) FROM #__hwdvidsvideos AS video $hwdvs_joinv $where" );
				$total = $db->loadResult();

				$pageNav = new JPagination( $total, $limitstart, $limit );

				$query = 'SELECT'.$hwdvs_selectv
						. ' FROM #__hwdvidsvideos AS video'
						. $hwdvs_joinv
						. ' LEFT JOIN #__hwdvidscategories AS `access` ON access.id = video.category_id'
						. $where
						. ' ORDER BY video.date_uploaded DESC'
						;
				$db->SetQuery($query, $pageNav->limitstart, $pageNav->limit);
				$rows = $db->loadObjectList();

				$smartyvs->assign("title", "Uploads");
				$smartyvs->assign("select_uploads", "selected=\"selected\"");
				$type = "videos";

			break;
			case "favourites":

				$limit     = intval($c->vpp);

				$where = ' WHERE video.approved = "yes"';
				$where .= ' AND video.published = 1';
				$where .= ' AND f.userid = '.$channel->user_id;

				$db->SetQuery( "SELECT count(*) FROM #__hwdvidsvideos AS video $hwdvs_joinv LEFT JOIN #__hwdvidsfavorites AS f ON video.id = f.videoid $where" );
				$total = $db->loadResult();

				$pageNav = new JPagination( $total, $limitstart, $limit );

				$query = 'SELECT'.$hwdvs_selectv
						. ' FROM #__hwdvidsvideos AS video'
						. $hwdvs_joinv
						. ' LEFT JOIN #__hwdvidsfavorites AS f ON video.id = f.videoid'
						. $where
						. ' ORDER BY video.date_uploaded DESC'
						;
				$db->SetQuery($query, $pageNav->limitstart, $pageNav->limit);
				$rows = $db->loadObjectList();

				$smartyvs->assign("title", "Favourite Videos");
				$smartyvs->assign("select_favourites", "selected=\"selected\"");
				$type = "videos";

			break;
			case "viewed":

				$limit     = intval($c->vpp);

				$where = ' WHERE video.approved = "yes"';
				$where .= ' AND video.published = 1';
				$where .= ' AND f.userid = '.$channel->user_id;

				$db->SetQuery( "SELECT count(*) FROM #__hwdvidsvideos AS video $hwdvs_joinv LEFT JOIN #__hwdvidslogs_views AS f ON video.id = f.videoid $where" );
				$total = $db->loadResult();

				$pageNav = new JPagination( $total, $limitstart, $limit );

				$query = 'SELECT'.$hwdvs_selectv
						. ' FROM #__hwdvidsvideos AS video'
						. $hwdvs_joinv
						. ' LEFT JOIN #__hwdvidslogs_views AS f ON video.id = f.videoid'
						. $where
						. ' ORDER BY f.date DESC'
						;
				$db->SetQuery($query, $pageNav->limitstart, $pageNav->limit);
				$rows = $db->loadObjectList();

				$smartyvs->assign("title", "Recently Viewed");
				$smartyvs->assign("select_viewed", "selected=\"selected\"");
				$type = "videos";

			break;
			case "liked":

				$limit     = intval($c->vpp);

				$where = ' WHERE video.approved = "yes"';
				$where .= ' AND video.published = 1';
				$where .= ' AND f.userid = '.$channel->user_id;
				$where .= ' AND f.vote > 3';

				$db->SetQuery( "SELECT count(*) FROM #__hwdvidsvideos AS video $hwdvs_joinv LEFT JOIN #__hwdvidslogs_votes AS f ON video.id = f.videoid $where" );
				$total = $db->loadResult();

				$pageNav = new JPagination( $total, $limitstart, $limit );

				$query = 'SELECT'.$hwdvs_selectv
						. ' FROM #__hwdvidsvideos AS video'
						. $hwdvs_joinv
						. ' LEFT JOIN #__hwdvidslogs_votes AS f ON video.id = f.videoid'
						. $where
						. ' ORDER BY f.date DESC'
						;
				$db->SetQuery($query, $pageNav->limitstart, $pageNav->limit);
				$rows = $db->loadObjectList();

				$smartyvs->assign("title", "Recently Liked Videos");
				$smartyvs->assign("select_liked", "selected=\"selected\"");
				$type = "videos";

			break;
			case "disliked":

				$limit     = intval($c->vpp);

				$where = ' WHERE video.approved = "yes"';
				$where .= ' AND video.published = 1';
				$where .= ' AND f.userid = '.$channel->user_id;
				$where .= ' AND f.vote < 3';

				$db->SetQuery( "SELECT count(*) FROM #__hwdvidsvideos AS video $hwdvs_joinv LEFT JOIN #__hwdvidslogs_votes AS f ON video.id = f.videoid $where" );
				$total = $db->loadResult();

				$pageNav = new JPagination( $total, $limitstart, $limit );

				$query = 'SELECT'.$hwdvs_selectv
						. ' FROM #__hwdvidsvideos AS video'
						. $hwdvs_joinv
						. ' LEFT JOIN #__hwdvidslogs_votes AS f ON video.id = f.videoid'
						. $where
						. ' ORDER BY f.date DESC'
						;
				$db->SetQuery($query, $pageNav->limitstart, $pageNav->limit);
				$rows = $db->loadObjectList();

				$smartyvs->assign("title", "Recently Disliked Videos");
				$smartyvs->assign("select_disliked", "selected=\"selected\"");
				$type = "videos";

			break;
			case "groups":

				$limit     = intval($c->gpp);

				$where = ' WHERE g.adminid = '.$user_id;
				$where .= ' AND g.published = 1';

				$db->SetQuery( "SELECT count(*) FROM #__hwdvidsgroups AS g $where" );
				$total = $db->loadResult();

				$pageNav = new JPagination( $total, $limitstart, $limit );

				$query = 'SELECT'.$hwdvs_selectg
						. ' FROM #__hwdvidsgroups AS g'
						. $hwdvs_joing
						. $where
						. ' ORDER BY g.date DESC'
						;
				$db->SetQuery($query, $pageNav->limitstart, $pageNav->limit);
				$rows = $db->loadObjectList();

				$smartyvs->assign("title", "Groups");
				$smartyvs->assign("select_groups", "selected=\"selected\"");
				$type = "groups";

			break;
			case "playlists":

				$limit     = intval($c->gpp);

				$where = ' WHERE pl.published = 1';
				$where.= ' AND pl.user_id = '.$user_id;

				$db->SetQuery( "SELECT count(*) FROM #__hwdvidsplaylists AS pl $where" );
				$total = $db->loadResult();

				$pageNav = new JPagination( $total, $limitstart, $limit );

				$query = 'SELECT * FROM #__hwdvidsplaylists AS pl'
						. $where
						. ' ORDER BY pl.date_created DESC'
						;
				$db->SetQuery($query, $pageNav->limitstart, $pageNav->limit);
				$rows = $db->loadObjectList();

				$smartyvs->assign("title", "Playlists");
				$smartyvs->assign("select_playlists", "selected=\"selected\"");
				$type = "playlists";

			break;
			case "memberships":

				$limit     = intval($c->gpp);

				$where = ' WHERE m.approved = 1';
				$where.= ' AND m.memberid = '.$user_id;
				$where.= ' AND g.published = 1';

				$db->SetQuery( "SELECT count(*) FROM #__hwdvidsgroup_membership AS m LEFT JOIN #__hwdvidsgroups AS g ON m.groupid = g.id $where" );
				$total = $db->loadResult();

				$pageNav = new JPagination( $total, $limitstart, $limit );

				$query = 'SELECT'.$hwdvs_selectg
						. ' FROM #__hwdvidsgroup_membership AS m'
						. ' LEFT JOIN #__hwdvidsgroups AS g ON m.groupid = g.id'
						. $hwdvs_joing
						. $where
						. ' ORDER BY m.date DESC'
						;
				$db->SetQuery($query, $pageNav->limitstart, $pageNav->limit);
				$rows = $db->loadObjectList();

				$smartyvs->assign("title", "Group Memberships");
				$smartyvs->assign("select_memberships", "selected=\"selected\"");
				$type = "groups";

			break;
			case "subscriptions":

				$smartyvs->assign("title", "Subscriptions");
				$smartyvs->assign("select_subscriptions", "selected=\"selected\"");
				$type = "subscriptions";

			break;
		}

        ////////////////////

		$where = ' WHERE video.approved = "yes"';
		$where .= ' AND video.published = 1';
		$where .= ' AND f.userid = '.$channel->user_id;

		$query = 'SELECT'.$hwdvs_selectv
               	. ' FROM #__hwdvidsvideos AS video'
				. $hwdvs_joinv
				. ' LEFT JOIN #__hwdvidsfavorites AS f ON video.id = f.videoid'
				. $where
				. ' ORDER BY video.date_uploaded DESC'
				. ' LIMIT 0, 5'
				;

		$db->SetQuery($query);
		$rows_favourites = $db->loadObjectList();

        ////////////////////

		$where = ' WHERE video.approved = "yes"';
		$where .= ' AND video.published = 1';
		$where .= ' AND f.userid = '.$channel->user_id;

		$query = 'SELECT'.$hwdvs_selectv
               	. ' FROM #__hwdvidsvideos AS video'
				. $hwdvs_joinv
				. ' LEFT JOIN #__hwdvidslogs_views AS f ON video.id = f.videoid'
				. $where
				. ' ORDER BY f.date DESC'
				. ' LIMIT 0, 5'
				;

		$db->SetQuery($query);
		$rows_recentlyviewed = $db->loadObjectList();

        ////////////////////

		hwd_vs_html::viewChannel($channel, $rows, $type, $pageNav, $total, $rows_favourites, $rows_recentlyviewed);
	}