Jump to content

How can I make WMV play on server side command?


alco19357

Recommended Posts

Hi there, I have a software/application developed by Agile. I have modified the script for the file page so that it will not only "download" or buffer, but play the WMV file in a page called by the function "playinwindow". The website has been protected and the domain name has been stripped. Code is below. My problem is this: when I launch the page: index.php?_page=file:playinwindow&id=8, it should execute the playinwindow function, which will execute the "download" function, since the src for the wmv file is: index.php?_page=file:download&id=8 (escape will change nothing).

 

This "server-side buffering" of the file (whose original content is protected in a .dat file) works without problem on IE. However, it won't play anything in Firefox.

 

Please help!! Thanks, Alex. Code below:

##############################
##		PLAY UPDATE         ##
##############################
function playinwindow($VAR)
{
	$db     = &DB();
	$sql    = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'file WHERE
				site_id     = ' . DEFAULT_SITE . ' AND
				id          = ' . $db->qstr(@$VAR['id']) . ' AND
				status      = 1';
	$result = $db->Execute($sql);

	if($result->RecordCount() == 1)
	{
		$show = true;

		### Validate start date
		$s = $result->fields['date_start']; 
		if($s != '' && $s != 0)
			if($s > time())
				$show = false; 

		### Validate expire date	
		$e = $result->fields['date_expire'];
		if($e != '' && $e != 0)
			if($e < time())
				$show = false;           					

		### Validate user group: 
		if($show) {
			global $C_auth;
			@$arr = unserialize($result->fields['group_avail']);
			$show = false; 
			for($i=0; $i<count($arr); $i++) {
				if($C_auth->auth_group_by_id($arr[$i]))  {
					$show = true;		
					break;
				}
			}                
		} 

		### Get the filetype
		if($show) 
		{
			$ft = $result->fields['location_type'];
			if($ft == 0)
				$file = PATH_FILES . 'file_'.$VAR['id'].'.dat';
			elseif ($ft == 1)
				$file = $result->fields['location'];
			elseif ($ft == 2)
				$file = $result->fields['location'];

			### Open the file
			if (@$file=fopen($file, 'r'))
			{  

				### Play the file in Windows Media Player:
				echo '<center>';
				echo '<table width="500" border="0" cellpadding="0" cellspacing="0">';
				echo '<tr><td align="left"><a href="?_page=file:file">Back</a></td></tr><tr><td height="10"></td></tr>';
				echo '<tr><td align="left"><strong>'.$result->fields['name'].'</strong></td></tr>';
				echo '<tr><td align="left">'.$result->fields['description'].'</td></tr>';
				echo '<tr><td height="10"></td></tr>';
				echo '<tr><td align="left">';
				echo '<OBJECT id=\'mediaPlayer\' width="500" height="450" 
      classid=\'CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95\' 
      codebase=\'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112\'
      standby=\'Loading Microsoft Windows Media Player components...\' type=\'application/x-oleobject\'>';
				//echo '<param name=\'fileName\' value="'.$result->fields['name'].'">';
				//   src="'.$result->fields['name'].'"
				echo '<param name=\'fileName\' value="http://SITEPROTECTED.com/?_page=file:download&_escape=1&id=12">';
				echo '<param name=\'animationatStart\' value=\'true\'>';
				echo '<param name=\'transparentatStart\' value=\'true\'>';
				echo '<param name=\'autoStart\' value="true">';
				echo '<param name=\'showControls\' value="true">';
				echo '<param name=\'loop\' value="true">';
				echo '<EMBED type=\'application/x-mplayer2\'
        pluginspage=\'http://microsoft.com/windows/mediaplayer/en/download/\'
        id=\'mediaPlayer\' name=\'mediaPlayer\' displaysize=\'4\' autosize=\'-1\' 
        bgcolor=\'darkblue\' showcontrols="true" showtracker=\'-1\' 
        showdisplay=\'0\' showstatusbar=\'-1\' videoborder3d=\'-1\' width="500" height="450"
        src="http://SITEPROTECTED.com/?_page=file:download&_escape=1&id=12" autostart="true" designtimesp=\'5311\' loop="true">';
				echo '</EMBED>';

				echo '</OBJECT>';
				echo '</td></tr></table></center>';
			}else{
				echo 'Sorry, the file does not exist.';
			}
		}else{
			echo 'Sorry, you are not authorized to view this file.';
		}
	}else{
		echo 'Sorry, your access has expired.';
	}
}




##############################
##		DOWNLOAD            ##
##############################
function download2($VAR)
{
	echo 'Module disabled.';
}

function download($VAR)
{
	$db     = &DB();
	$sql    = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'file WHERE
				site_id     = ' . DEFAULT_SITE . ' AND
				id          = ' . $db->qstr(@$VAR['id']) . ' AND
				status      = 1';
	$result = $db->Execute($sql);

	if($result->RecordCount() == 1)
	{
		$show = true;

		### Validate start date
		$s = $result->fields['date_start']; 
		if($s != '' && $s != 0)
			if($s > time())
				$show = false; 

		### Validate expire date	
		$e = $result->fields['date_expire'];
		if($e != '' && $e != 0)
			if($e < time())
				$show = false;           					

		### Validate user group: 
		if($show) {
			global $C_auth;
			@$arr = unserialize($result->fields['group_avail']);
			$show = false; 
			for($i=0; $i<count($arr); $i++) {
				if($C_auth->auth_group_by_id($arr[$i]))  {
					$show = true;		
					break;
				}
			}                
		} 

		### Get the filetype
		if($show) 
		{
			$ft = $result->fields['location_type'];
			if($ft == 0)
				$file = PATH_FILES . 'file_'.$VAR['id'].'.dat';
			elseif ($ft == 1)
				$file = $result->fields['location'];
			elseif ($ft == 2)
				$file = $result->fields['location'];

			### Open the file
			if (@$file=fopen($file, 'r'))
			{  
				### Display the correct headers:
				header ("Content-Type: " . $result->fields['type']);
				header ("Content-Size: " . $result->fields['size']);
				header ("Content-Disposition: inline; filename=" . $result->fields['name']);  
				header ("Content-Length: " . $result->fields['size']);         	            	
				fpassthru($file);
				exit;                                     
			}
		}
	}
	echo 'Sorry, the file does not exist or you are not authorized or your access has expired!';
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.