Location: PHPKode > projects > PHP Media Manager with IMDB > encoder.php
<?php
// All static data  and functionsimported from here.
include 'config.php';
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title>Flash video encoder and player</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>

<?php
//checks if the form has been submitted.
if(isset($_POST['Submit']))
{
//get the original name of the file from the clients machine.
$filename = rawurldecode(stripslashes($_POST['fullfile']));
echo $filename."<br />";
$fname = stripslashes($_POST['fname']);
echo $fname."<br />";
//get the extension of the file in a lower case format.
$extension = getExtension($filename);
$extension = strtolower($extension);
}
else
{
exit ("<p>Another page needs to POST necessary data to this one in order for it to work. These data have not been received or are unusable.</p>
<p>Required POST fields are: fullfile (file name including path), fname (filename on its own)</p>");
};
// check it's a valid format
if (!in_array($extension, $movielist))
{
//print error message.
exit ("<h1>The file format ".$extension." you have chosen cannot be converted to flash video</h1>");
};

// check for filename match with already-recoded videos
mysql_query("select id from encoded where fname='".$fname."'");
if (mysql_affected_rows() >= 1)
{
$getid = mysql_query("select id from encoded where fname='".$fname."'");
while($row = mysql_fetch_assoc($getid))
{
$id = $row['id'];
};

echo "
<p>Video already encoded (db entry exists), so skipping the next bit - contact sysadmin if this is wrong.</p>
<script type=\"text/javascript\">
<!--
setTimeout('window.location = \"gen.php?id=".$id."\",\"width=100,height=100\"', ".$already_timeout.");
//-->
</script>
";
}
else
{
mysql_query("insert into encoded (fname,filename) values ('".$fname."','".$filename."')");
$id = mysql_insert_id();
echo "
<p>Your video is currently recoding. Depending how big it is and the, power of the server, this could take quite some time. Please do not close explorer windows during this time. You also need to allow popups from this site for the encoding to take place.</p>
<script type=\"text/javascript\">
var encode;
encode = window.open(\"encode.php?id=".$id."\", encode);
while (encode) 
{
sleep (10);
}
</script>
";
echo "<p>If you reckon server load is low, and are the impatient sort, you can try watching the video while it recodes <a href=\"gen.php?id=".$id."\">here</a>. Please note that, until video is fully encoded, skipping and the progress bar bar will not function properly.</p>";
};
?>
</body>
</html>
Return current item: PHP Media Manager with IMDB