示例#1
0
    /**
     * Query SQL for all accessible category data
     *
     * @return       Nothing
     */
    function downloadFile()
    {
        global $mainframe, $limitstart;
		$c = hwd_vs_Config::get_instance();
		$db = & JFactory::getDBO();
		$my = & JFactory::getUser();
		$acl= & JFactory::getACL();
		$usersConfig = &JComponentHelper::getParams( 'com_users' );

		//$currentSession = JSession::getInstance('none',array());
		//$currentSession->destroy();

		$evp = JRequest::getCmd( 'evp', 0 );
		$file = JRequest::getCmd( 'file', 0 );
		$deliver = JRequest::getCmd( 'deliver', 0 );
		$media = JRequest::getCmd( 'media', 0 );
		$fix = JRequest::getCmd( 'fix', 0 );
		$streamer = JRequest::getCmd( 'streamer', 'off' );
		$quality = JRequest::getCmd( 'quality', 'hd' );
		$pushDownload = false;
		$showError = false;

		// get video details
		$db->SetQuery( 'SELECT * FROM #__hwdvidsvideos WHERE id = '.(int)$file );
		$db->Query();
		$row = $db->loadObject();

        $db->SetQuery( 'SELECT count(*) FROM #__hwdvidsantileech WHERE expiration = "'.$evp.'"' );
        $result = $db->loadResult();
		if ($result > 0 || $c->use_protection == 0 || $row->allow_embedding == "1")
		{
			$location = hwd_vs_tools::generateVideoLocations( $row, $quality );
			$location['ext'] = "flv";

			$db->SetQuery( 'SELECT `count` FROM #__hwdvidsantileech WHERE expiration = "'.$evp.'"' );
			$count = $db->loadResult();

			if ($row->allow_embedding == 1 && $c->showvebc == 1)
			{
				$pushDownload = true;
			}
			else if ($count < $c->protection_level)
			{
				$newCount = $count+1;
				$db->SetQuery( "UPDATE #__hwdvidsantileech SET `count` = $newCount WHERE expiration = \"".$evp."\"" );
				$db->Query();

				if ($deliver !== "player")
				{
					if (!hwd_vs_access::allowAccess( $c->gtree_dnld, $c->gtree_dnld_child, hwd_vs_access::userGID( $my->id )))
					{
						$pushDownload = false;
					}
					else
					{
						$pushDownload = true;
					}
				}
				else if ($deliver == "player")
				{
					$pushDownload = true;
				}
			}
			else
			{
				$showError = true;
			}

			if ($deliver == "downloadoriginal" || $deliver == "original")
			{
				if ($handle = opendir(JPATH_SITE.DS.'hwdvideos'.DS.'uploads'.DS.'originals'))
				{
					$url = '';

					while (false !== ($file = readdir($handle)))
					{
						list($filename_noext, $filename_ext) = @split('\.', basename($file));

						if ($filename_noext == $row->video_id)
						{
							$location['url']  = JURI::root().'hwdvideos/uploads/originals/'.$file;
							$location['path'] = JPATH_SITE.DS.'hwdvideos'.DS.'uploads'.DS.'originals'.DS.$file;
							$location['ext'] = $filename_ext;
						}
					}

					closedir($handle);
				}
			}
			else if ($deliver == "flv")
			{
				if (file_exists(JPATH_SITE.DS."hwdvideos".DS."uploads".DS.$row->video_id.".flv"))
				{
					$location['url']  = JURI::root()."hwdvideos/uploads/".$row->video_id.".flv";
					$location['path'] = JPATH_SITE.DS."hwdvideos".DS."uploads".DS.$row->video_id.".flv";
					$location['ext'] = "flv";
				}
			}
			else if ($deliver == "h264")
			{
				if (file_exists(JPATH_SITE.DS."hwdvideos".DS."uploads".DS.$row->video_id.".mp4"))
				{
					$location['url']  = JURI::root()."hwdvideos/uploads/".$row->video_id.".mp4";
					$location['path'] = JPATH_SITE.DS."hwdvideos".DS."uploads".DS.$row->video_id.".mp4";
					$location['ext'] = "mp4";
				}
			}
			else if ($deliver == "ipod340")
			{
				if (file_exists(JPATH_SITE.DS."hwdvideos".DS."uploads".DS.$row->video_id.".ipod320.mp4"))
				{
					$location['url']  = JURI::root()."hwdvideos/uploads/".$row->video_id.".ipod320.mp4";
					$location['path'] = JPATH_SITE.DS."hwdvideos".DS."uploads".DS.$row->video_id.".ipod320.mp4";
					$location['ext'] = "ipod320.mp4";
				}
			}
			else if ($deliver == "ipod640")
			{
				if (file_exists(JPATH_SITE.DS."hwdvideos".DS."uploads".DS.$row->video_id.".ipod640.mp4"))
				{
					$location['url']  = JURI::root()."hwdvideos/uploads/".$row->video_id.".ipod640.mp4";
					$location['path'] = JPATH_SITE.DS."hwdvideos".DS."uploads".DS.$row->video_id.".ipod320.mp4";
					$location['ext'] = "ipod640.mp4";
				}
			}

			if ($pushDownload)
			{
				if (headers_sent($filename, $linenum) || $row->video_type == "seyret" || $row->video_type == "remote")
				{
					$mainframe->redirect( $location['url'] );
				}
				else if ($deliver == "player")
				{
					header('Location: '.$location['url']);
					exit;
				}
				else
				{
					// Transfer file in chunks to preserve memory on the server
					$fn = basename($location['path']);

					$title = str_replace(" ", "-", $row->title);
					$title = preg_replace("/[^a-zA-Z0-9s-]/", "", $title);

					if (!empty($title)) {
						$ftitle = $title.".".$location['ext'];
					} else {
						$ftitle = $fn;
					}

					header('Content-Type: application/octet-stream');
					header("Content-Disposition: attachment; filename=\"$ftitle\"");
					header('Content-Length: '.filesize($location['path']));
					@hwd_vs_tools::readfile_chunked($location['path'], true);
					exit;
				}
			}
		}

		if ($count > $c->protection_level)
		{
			$db->SetQuery("DELETE FROM #__hwdvidsantileech WHERE expiration = \"$evp\"");
			$db->Query();
		}

		$showError = true;

		$hwdvsItemid = hwd_vs_tools::generateValidItemid();

		$msg = "You do not have access to this file using the requested method.";
		$mainframe->enqueueMessage($msg);
		$mainframe->redirect( JURI::root()."index.php?option=com_hwdvideoshare&Itemid=".$hwdvsItemid."&task=viewvideo&video_id=".$row->id );

    }
示例#2
0
    /**
     * Make xml playlist file
     *
     * @return       True
     */
    function XMLPlaylistFile($rows, $filename)
    {
		$db =& JFactory::getDBO();
		$c = hwd_vs_Config::get_instance();
    	jimport('joomla.filesystem.file');

		$config = null;
		$config .= "<playlist version=\"1\" xmlns=\"http://xspf.org/ns/0/\">\n";
		$config .= "<title>hwdVideoShare Playlist</title>\n";
		$config .= "<info>http:/xspf.org/xspf-v1.html</info>\n";
		$config .= "<date>".date('Y-m-d H:i:s')."</date>\n";
		$config .= "<trackList>\n";
		$config .= "\n";

		// print out playlist
		for ($i=0, $n=count($rows); $i < $n; $i++)
		{
			$row = $rows[$i];

			$type = "video";

			if (($row->video_type == "youtube.com" || ($row->video_type == "seyret" && substr($row->video_id, 0, 7) == "youtube")) && ($c->hwdvids_videoplayer_file == "jwflv" || $c->hwdvids_videoplayer_file == "jwflv_v5"))
			{
				$data = @explode(",", $row->video_id);
				if ($row->video_type == "seyret")
				{
					$YTID = $data[1];
				}
				else
				{
					$YTID = $data[0];
				}

				$location = "http://www.youtube.com/watch?v=".$YTID;
				$image = hwd_vs_tools::generatePlayerThumbnail($row);
				$type = "youtube";
			}
			else
			{
				$locations = hwd_vs_tools::generateVideoLocations($row);
				$location = $locations['url'];
				$image = hwd_vs_tools::generatePlayerThumbnail($row);
			}

			if (empty($location)) continue;

			//$title      = hwd_vs_tools::truncateText(strip_tags(hwdEncoding::UNXMLEntities($row->title)), 50);
			//$annotation = hwd_vs_tools::truncateText(strip_tags(hwdEncoding::UNXMLEntities($row->description)), 50);

			$title      = strip_tags(hwdEncoding::UNXMLEntities($row->title));
			$annotation = strip_tags(hwdEncoding::UNXMLEntities($row->description));
			$image = urldecode($image);

		    $config .= "  <track>\n";
		    $config .= "    <location><![CDATA[".$location."]]></location>\n";
		    $config .= "    <image><![CDATA[".$image."]]></image>\n";
		    $config .= "    <title><![CDATA[".$title."]]></title>\n";
		    $config .= "    <annotation><![CDATA[".$annotation."]]></annotation>\n";
			$config .= "	<meta rel='type'>".$type."</meta>\n";
		    $config .= "  </track>\n";
		    $config .= "\n";
		}

		$config .= "</trackList>\n";
		$config .= "</playlist>\n";

		$configFile = JPATH_SITE.DS.'components'.DS.'com_hwdvideoshare'.DS.'xml'.DS.'xspf'.DS.$filename.'.xml';
		if (!JFile::write($configFile, $config)) {
			return false;
		}

		return true;
    }
    /**
     * Generates the video player
     *
     * @param array  $row  the video sql data
     * @param int    $width(optional)  the video player width
     * @param int    $height(optional)  the video player width
     * @return       $code
     */
	function generateVideoPlayer( $row, $width=null, $height=null, $autostart=null, $quality="hd", $embedcode=false )
	{
		global $hwdvsItemid, $mainframe, $option, $task, $smartyvs, $show_video_ad, $pre_url, $post_url, $j15, $j16;
		$c = hwd_vs_Config::get_instance();
  		$db =& JFactory::getDBO();

		if (!isset($row->age_check)) { $row->age_check = "-1"; }
		if (($c->age_check > 0 && $row->age_check == "-1") || $row->age_check > 0)
		{
			$age_response = hwd_vs_tools::generateAgeCheck($row);
			if ($age_response !== true)
			{
				if ($embedcode == true)
				{
				}
				else
				{
					if ($age_response !== true)
					{
						return $age_response;
					}
				}
			}
		}

		if ($j16)
		{
			$vp_plugin_path = JPATH_SITE.DS."plugins".DS."hwdvs-videoplayer".DS.$c->hwdvids_videoplayer_file.DS.$c->hwdvids_videoplayer_file.".view.php";
		}
		else
		{
			$vp_plugin_path = JPATH_SITE.DS."plugins".DS."hwdvs-videoplayer".DS.$c->hwdvids_videoplayer_file.".view.php";
		}

		if (file_exists($vp_plugin_path))
		{
			require_once($vp_plugin_path);
		}
		else if (file_exists(JPATH_SITE.DS."plugins".DS."hwdvs-videoplayer".DS."flow.view.php"))
		{
			require_once(JPATH_SITE.DS."plugins".DS."hwdvs-videoplayer".DS."flow.view.php");
		}
		else if (file_exists(JPATH_SITE.DS."plugins".DS."hwdvs-videoplayer".DS."flow".DS."flow.view.php"))
		{
			require_once(JPATH_SITE.DS."plugins".DS."hwdvs-videoplayer".DS."flow".DS."flow.view.php");
		}
		else
		{
        	return "This video can not be displayed because there are no video players installed.";
		}

		$player = new hwd_vs_videoplayer();
		$flv_url = null;
		$flv_path = null;
		$thumb_url = null;
		$use_xMoovphp = false;
		$code = null;

		$location = hwd_vs_tools::generateVideoLocations($row, $quality);
		$thumb_url = hwd_vs_tools::generateThumbnailURL($row->id, @$row->video_id, $row->video_type, @$row->thumbnail, "large");

		if ($row->video_type == "local" || $row->video_type == "mp4" || $row->video_type == "swf")
		{
			// temporary html5 player fix
			if ($c->hwdvids_videoplayer_file == "jwflv_html5")
			{
				$c->use_protection = 0;
			}

			if ($c->storagetype !== "0")
			{
				$flv_url = $location['url'];
				$flv_path = $location['path'];
				$use_xMoovphp = $location['use_xMoovphp'];
				$dlink = $location['url'];
			}
			else if ($c->use_protection == 0)
			{
				$flv_url = $location['url'];
				$flv_path = $location['path'];
				$use_xMoovphp = $location['use_xMoovphp'];
				$dlink = $location['url'];
			}
			else
			{
				$flv_url = $location['url'];
				$flv_path = $location['path'];
				$use_xMoovphp = $location['use_xMoovphp'];
				$dlink = hwd_vs_tools::generateAntileechExpiration($row->id, $row->video_type, 'player', $quality);
				$dlink = urlencode($dlink);
			}

			if ($use_xMoovphp)
			{
				$pluginPlayer =& JPluginHelper::getPlugin("hwdvs-videoplayer", "$c->hwdvids_videoplayer_file");
				$pluginPlayerParams = new JParameter( $pluginPlayer->params );
				$pluginPlayerStreamer = $pluginPlayerParams->get('pseudostreaming', 0);

				if ($pluginPlayerStreamer == "1" && ($c->hwdvids_videoplayer_file == "jwflv" || $c->hwdvids_videoplayer_file == "jwflv_v5"))
				{
					$dlink = $row->video_id.".flv";
				}
			}

			if ( $row->video_type == "swf" && $c->standaloneswf == 1 )
			{
				$width = $c->flvplay_width;
				$height = $width*$c->var_fb;
				$smartyvs->assign("player_width", $width);
				$code.= "<div style=\"text-align: inherit;width:".$width."px!important;height:".$height."px!important;\">";
				$code.= "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" width=\"".$width."\" height=\"".$height."\" codebase=\"http://active.macromedia.com/flash7/cabs/ swflash.cab#version=9,0,0,0\">
						 <param name=\"movie\" value=\"".$flv_url."\">
						 <param name=\"play\" value=\"true\">
						 <param name=\"loop\" value=\"true\">
						 <param name=\"width\" value=\"".$width."\">
						 <param name=\"height\" value=\"".$height."\">
						 <param name=\"quality\" value=\"high\">
						 <param name=\"allowscale\" value=\"true\">
						 <param name=\"scale\" value=\"showall\">
						 <embed src=\"".$flv_url."\" width=\"".$width."\" height=\"".$height."\" play=\"true\" scale=\"showall\" loop=\"true\" quality=\"high\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" swLiveConnect=\"true\">
						 </embed>
						 </object>";
				return $code;
			}

			if ($show_video_ad == 1 && !$embedcode)
			{
				if ($c->hwdvids_videoplayer_file == "flow")
				{
					$flv_tracks = array();
					$flv_tracks[0] = $pre_url;
					$flv_tracks[1] = $dlink;
					$flv_tracks[2] = $post_url;
					$code.= $player->prepareEmbeddedPlayer($flv_tracks, $width, $height, rand(100, 999), "playlist", $flv_path, null, $autostart);
					return $code;
				}
				else
				{
					$xspf_playlist = JPATH_SITE.DS."components".DS."com_hwdvideoshare".DS."xml".DS."xspf".DS.$row->id.".xml";
					@unlink($xspf_playlist);
					require_once(JPATH_SITE.DS."administrator".DS."components".DS."com_hwdrevenuemanager".DS."redrawplaylist.class.php");
					hwd_rm_playlist::writeFile($row, $dlink, $pre_url, $post_url, $thumb_url, $use_xMoovphp);

					if (file_exists($xspf_playlist))
					{
						$flv_url = JURI::root(true).'/components/com_hwdvideoshare/xml/xspf/'.$row->id.'.xml';
						$flv_path = JPATH_SITE.DS."components".DS."com_hwdvideoshare".DS."xml".DS."xspf".DS.$row->id.".xml";

						if ($c->loadswfobject == "on" && $task !=="grabjomsocialplayer")
						{
							$code.= $player->prepareplayer($flv_url, $width, $height, rand(100, 999), "playlist", $flv_path, null, $autostart, $row->id);
						}
						else
						{
							$code.= $player->prepareEmbeddedPlayer($flv_url, $width, $height, rand(100, 999), "playlist", $flv_path, null, $autostart, $row->id);
						}
					}
				}
			}
			else
			{
				if ($c->loadswfobject == "on" && $task !=="grabjomsocialplayer" && !$embedcode)
				{
					$code.= $player->prepareplayer($dlink, $width, $height, rand(100, 999), "video", $flv_path, $thumb_url, $autostart, $row->id);
				}
				else if (!$embedcode)
				{
					$code.= $player->prepareEmbeddedPlayer($dlink, $width, $height, rand(100, 999), "video", $flv_path, $thumb_url, $autostart, $row->id);
				}
				else
				{
					$code.= $player->prepareEmbedCode($dlink, $width, $height, rand(100, 999), "video", $flv_path, $thumb_url, $autostart, $row->id);
				}
			}
		}
		else if ( $row->video_type == "playlist" )
		{
			$flv_path = $row->playlist;
			if ($c->loadswfobject == "on")
			{
				$code.= $player->prepareplayer($flv_path, $width, $height, rand(100, 999), "playlist", null, null, $autostart, null);
			}
			else
			{
				$code.= $player->prepareEmbeddedPlayer($flv_path, $width, $height, rand(100, 999), "playlist", null, null, $autostart, null);
			}
		}
		else if ( $row->video_type == "direct" )
		{
			$code.= $player->prepareEmbeddedPlayer($row->video_url, $width, $height, rand(100, 999), "video", $flv_path, $thumb_url, $autostart, $row->id);
		}
		else if ($row->video_type == "seyret")
		{
			if (@explode(",", $video_code))
			{
				$data = explode(",", $row->video_id);
			}
			else
			{
				return;
			}
			if ($data[0] == "local")
			{
				$file->id = $row->id;
				$file->video_type = "remote";
				if (!empty($data[2]))
				{
					$file->video_id = @$data[1].",".@$data[2];
				}
				else
				{
					$file->video_id = @$data[1];
				}
				$file->thumbnail = $row->thumbnail;
				$code.= hwd_vs_tools::generateVideoPlayer($file, $width, $height, $autostart, $quality, $embedcode);
			}
			else
			{
				$file->id = $row->id;
				$file->video_type = $data[0];
				if (!empty($data[2]))
				{
					$file->video_id = @$data[1].",".@$data[2];
				}
				else
				{
					$file->video_id = @$data[1];
				}
				$file->thumbnail = $row->thumbnail;
				$code.= hwd_vs_tools::generateVideoPlayer($file, $width, $height, $autostart, $quality, $embedcode);
			}
		}
		else
		{
			$plugin = hwd_vs_tools::getPluginDetails($row->video_type);
			if (!$plugin)
			{
				if ($width==null)
				{
					$smartyvs->assign("player_width", $c->tpwidth);
				}
				else
				{
					$smartyvs->assign("player_width", $width);
				}
				$code.= _HWDVIDS_INFO_NOPLUGIN." "._HWDVIDS_WMIP_01.$row->video_type._HWDVIDS_WMIP_02;
			}
			else
			{
				if (!$embedcode)
				{
					$preparevid = preg_replace("/[^a-zA-Z0-9s_-]/", "", $row->video_type)."PrepareVideo";
					$code.= $preparevid($row, $width, $height, $autostart);
				}
				else
				{
					$preparevid = preg_replace("/[^a-zA-Z0-9s_-]/", "", $row->video_type)."PrepareVideoEmbed";
					$code.= $preparevid($row->video_id, $row->id, $hwdvsItemid, $row);
				}
			}
		}

		if (!$embedcode)
		{
			return "<div id=\"hwdvsplayer\">".$code."</div>";
		}
		else
		{
			return $code;
		}
	}