22
Dynamic Flash Images: Dynamic Flash Images: Increased Functionality Increased Functionality and Copy Protection for and Copy Protection for Online Images Online Images Jason W. Nadal

Dynamic Flash Images: Increased Functionality and Copy Protection for Online Images Jason W. Nadal

Embed Size (px)

Citation preview

Page 1: Dynamic Flash Images: Increased Functionality and Copy Protection for Online Images Jason W. Nadal

Dynamic Flash Images:Dynamic Flash Images:

Increased Functionality and Increased Functionality and Copy Protection for Online Copy Protection for Online

ImagesImages

Jason W. Nadal

Page 2: Dynamic Flash Images: Increased Functionality and Copy Protection for Online Images Jason W. Nadal

The ProcessThe Process

Page 3: Dynamic Flash Images: Increased Functionality and Copy Protection for Online Images Jason W. Nadal

DatabaseDatabase

•Initial Database stores long blob info, actually the binary contents of the image.

CREATE TABLE testjpgs (

id INT(4) NOT NULL AUTO_INCREMENT PRIMARY KEY,

description CHAR(255),bin_data LONGBLOB,filename CHAR(255),filesize CHAR(50),filetype CHAR(50)

); •Database could be either in MySQL, Access, or any other data source accessible through either PHP or ASP.

Page 4: Dynamic Flash Images: Increased Functionality and Copy Protection for Online Images Jason W. Nadal
Page 5: Dynamic Flash Images: Increased Functionality and Copy Protection for Online Images Jason W. Nadal

STORE.PHPSTORE.PHP (Client View) (Client View)

Adds the Image Adds the Image from a disk or the from a disk or the server’s hard drive server’s hard drive to the database.to the database.

Data is then Data is then accessible through accessible through read.phpread.php

Page 6: Dynamic Flash Images: Increased Functionality and Copy Protection for Online Images Jason W. Nadal

STORE.PHP STORE.PHP (Back End)(Back End)<HTML><HTML><HEAD><TITLE>Store binary data into SQL Database<HEAD><TITLE>Store binary data into SQL Database</TITLE></TITLE></HEAD></HEAD><BODY><BODY><?php<?php// code that will be executed if the form has been // code that will be executed if the form has been

submitted:submitted:if ($submit) if ($submit) {{ // connect to the database// connect to the database

MYSQL_CONNECT("localhost","root","");MYSQL_CONNECT("localhost","root",""); mysql_select_db("imageDB");mysql_select_db("imageDB"); $form_data_size = filesize($form_data);$form_data_size = filesize($form_data);

$form_data_name = $form_data;$form_data_name = $form_data;$data = $data =

addslashes(fread(fopen($form_data, "r"), addslashes(fread(fopen($form_data, "r"),

filesize($form_data)));filesize($form_data))); $result=MYSQL_QUERY("INSERT INTO $result=MYSQL_QUERY("INSERT INTO

testJPGs(description,bin_data,testJPGs(description,bin_data,filename,filesize,filetype) ".filename,filesize,filetype) ".

"VALUES "VALUES ('$form_description',('$form_description',

'$data','$form_data_name','$data','$form_data_name', '$form_data_size','$form_data_type')");'$form_data_size','$form_data_type')");

$id= mysql_insert_id();$id= mysql_insert_id();

print "<p>This file has the following Database ID: print "<p>This file has the following Database ID: <b>$id</b>";<b>$id</b>";

?>?><img src="read.php?id=<?print"$id";?>"><img src="read.php?id=<?print"$id";?>"><? MYSQL_CLOSE();<? MYSQL_CLOSE();} else {} else {

// else show the form to submit new data:// else show the form to submit new data:?>?>

<form method="get" action="store.php" <form method="get" action="store.php" enctype="multipart/form-data">enctype="multipart/form-data">

File Description:<br>File Description:<br> <input type="text" name="form_description" <input type="text" name="form_description"

size="40">size="40"> <INPUT TYPE="hidden" name="MAX_FILE_SIZE" <INPUT TYPE="hidden" name="MAX_FILE_SIZE"

value="1000000">value="1000000"> <br>File to upload/store in database:<br><br>File to upload/store in database:<br> <input type="file" name="form_data" size="40"><input type="file" name="form_data" size="40"> <p><input type="submit" name="submit" <p><input type="submit" name="submit"

value="submit">value="submit"> </form></form><?php <?php }}?>?></BODY></BODY></HTML> </HTML>

Page 7: Dynamic Flash Images: Increased Functionality and Copy Protection for Online Images Jason W. Nadal

READ.PHP READ.PHP (Front End)(Front End)

READ.PHPREAD.PHP is available only on the is available only on the local network in order to only allow local network in order to only allow access to the full JPEG version of the access to the full JPEG version of the image for trusted machines.image for trusted machines.

READ.PHPREAD.PHP is passed one variable: the is passed one variable: the row number of the image in the row number of the image in the database ($id, ex. database ($id, ex. /read.php?id=4/read.php?id=4 ) )

Page 8: Dynamic Flash Images: Increased Functionality and Copy Protection for Online Images Jason W. Nadal

READ.PHPREAD.PHP (Back End) (Back End)

<?php<?phpif($id) {if($id) {

// you may have to modify login information for // you may have to modify login information for your database server:your database server:

@MYSQL_CONNECT("localhost","root","");@MYSQL_CONNECT("localhost","root","");

@mysql_select_db("imageDB");@mysql_select_db("imageDB");

$query = "select bin_data,filetype from $query = "select bin_data,filetype from testJPGs";testJPGs";

$result = @MYSQL_QUERY($query);$result = @MYSQL_QUERY($query);

$data = @MYSQL_RESULT($result,$id-$data = @MYSQL_RESULT($result,$id-1,"bin_data");1,"bin_data");

$type = @MYSQL_RESULT($result,$id-$type = @MYSQL_RESULT($result,$id-1,"filetype");1,"filetype");

Header( "Content-type: $type");Header( "Content-type: $type"); echo $data;echo $data;

};};?> ?>

Page 9: Dynamic Flash Images: Increased Functionality and Copy Protection for Online Images Jason W. Nadal

ServerWriteJPEG.dllServerWriteJPEG.dll

No existing ATL control will let the No existing ATL control will let the page take an image from a URL and page take an image from a URL and convert it to a single frame SWF convert it to a single frame SWF movie.movie.

ServerWriteJPEG.dllServerWriteJPEG.dll is a COM+ ATL is a COM+ ATL control written in Java (J++) to do control written in Java (J++) to do just thatjust that

Page 10: Dynamic Flash Images: Increased Functionality and Copy Protection for Online Images Jason W. Nadal

ServerWriteJPEG.dll (1)ServerWriteJPEG.dll (1)import java.awt.*;import java.awt.*;import java.awt.event.*;import java.awt.event.*;import java.net.*;import java.net.*;import java.io.*;import java.io.*;import java.applet.Applet;import java.applet.Applet;public class WriteJPEGpublic class WriteJPEG{{

public String copyFileFromURL(String theURL, String outFile)public String copyFileFromURL(String theURL, String outFile){{

//takes the file at fileURL and copies it to a file//takes the file at fileURL and copies it to a file//on the server's hard drive, destFile//on the server's hard drive, destFileURL url;URL url;try try {{

url = new URL(theURL); url = new URL(theURL); File outputFile = new File(outFile); File outputFile = new File(outFile); URLConnection conn = url.openConnection();URLConnection conn = url.openConnection();InputStream in = conn.getInputStream();InputStream in = conn.getInputStream();

FileOutputStream out = new FileOutputStream out = new FileOutputStream(outputFile); FileOutputStream(outputFile);

int c; int c; while ((c = in.read()) != -1) out.write(c);while ((c = in.read()) != -1) out.write(c);

in.close(); in.close(); out.close();out.close();

}}catch (Exception exc) {}catch (Exception exc) {}return "Finished.";return "Finished.";

}}

Page 11: Dynamic Flash Images: Increased Functionality and Copy Protection for Online Images Jason W. Nadal

ServerWriteJPEG.dll (2)ServerWriteJPEG.dll (2)public String copyFile(String inFile, String outFile)public String copyFile(String inFile, String outFile){{

//copies a file from the server to another location on the //copies a file from the server to another location on the server.server.

File inputFile = new File(inFile); File inputFile = new File(inFile); File outputFile = new File(outFile);File outputFile = new File(outFile);try try {{FileInputStream in = new FileInputStream(inputFile);FileInputStream in = new FileInputStream(inputFile);

FileOutputStream out = new FileOutputStream out = new FileOutputStream(outputFile);FileOutputStream(outputFile); int c;int c; while ((c = in.read()) != -1) out.write(c); while ((c = in.read()) != -1) out.write(c); in.close(); in.close();

out.close();out.close();}}catch (Exception exc) {}catch (Exception exc) {}return "Finished.";return "Finished.";

}}}}

Page 12: Dynamic Flash Images: Increased Functionality and Copy Protection for Online Images Jason W. Nadal

Temp Image File - TransitionTemp Image File - Transition

A temporary image file now exists on the A temporary image file now exists on the server. This paves the way for the file to server. This paves the way for the file to be converted into a single frame flash be converted into a single frame flash image.image.

Page 13: Dynamic Flash Images: Increased Functionality and Copy Protection for Online Images Jason W. Nadal
Page 14: Dynamic Flash Images: Increased Functionality and Copy Protection for Online Images Jason W. Nadal

J2S.dllJ2S.dll - The Conversion - The Conversion

This DLL file is an ATL control written in This DLL file is an ATL control written in C++, as part of a package to convert C++, as part of a package to convert images to flash movies.images to flash movies.

The component J2S.Converter.1 has the The component J2S.Converter.1 has the method Convert which takes 2 file method Convert which takes 2 file arguments, input and output, and arguments, input and output, and generates that SWF file on the backend generates that SWF file on the backend when the client requests a page.when the client requests a page.

Page 15: Dynamic Flash Images: Increased Functionality and Copy Protection for Online Images Jason W. Nadal

Swift-GeneratorSwift-Generator

Swift-Generator (swiftgen.exe) is a CGI Swift-Generator (swiftgen.exe) is a CGI program written in C/C++ that allows the program written in C/C++ that allows the programmer to add dynamic content to a programmer to add dynamic content to a flash movie.flash movie.

Swift-Generator takes 1 argument, the Swift-Generator takes 1 argument, the location of the SWS scripting file. (ie: location of the SWS scripting file. (ie: ““/cgi/swiftgen.exe?sws=/assets/sws/movie.s/cgi/swiftgen.exe?sws=/assets/sws/movie.swsws”)”)

SwiftGen then compiles the published SWT SwiftGen then compiles the published SWT template file along with any assets template file along with any assets mentioned in the SWS scripting file and mentioned in the SWS scripting file and creates the final compiled movie.creates the final compiled movie.

Page 16: Dynamic Flash Images: Increased Functionality and Copy Protection for Online Images Jason W. Nadal

mainMovie.swsmainMovie.sws

% Jason Nadal% Jason Nadal%% (c)2002(c)2002%% mainMovie.swsmainMovie.sws Swift-Generator Scripting fileSwift-Generator Scripting file%% Script template from Template file mainMovie.swtScript template from Template file mainMovie.swt%% compiles the Template File (mainMovie.swt) with the assets into the finalcompiles the Template File (mainMovie.swt) with the assets into the final%% result SWF movie when called with Swift-Generator CGI program.result SWF movie when called with Swift-Generator CGI program.

INPUT "../php/ccsc/flashMovie/mainMovie.swt"INPUT "../php/ccsc/flashMovie/mainMovie.swt"

% Output for testing% Output for testing%OUTPUT "export.swf"%OUTPUT "export.swf"% Output for CGI% Output for CGIOUTPUT -cgi "-"OUTPUT -cgi "-"

% Font definitions% Font definitions% FONT 4 is Times New Roman (224 glyphs)% FONT 4 is Times New Roman (224 glyphs)

SUBSTITUTE TEXT 5 {SUBSTITUTE TEXT 5 {FONT 4 HEIGHT 24 KERNING 0.98 COLOR #ffff80FONT 4 HEIGHT 24 KERNING 0.98 COLOR #ffff80STRING "Image Gallery - Protected Image"STRING "Image Gallery - Protected Image"

}}

Page 17: Dynamic Flash Images: Increased Functionality and Copy Protection for Online Images Jason W. Nadal

mainMovie.fla mainMovie.fla ActionScriptActionScript

The main movie file contains a separate The main movie file contains a separate movie instance from movie instance from _root_root which loads which loads the generated single frame looping the generated single frame looping image movie using the command:image movie using the command:

loadMovie("image.swf",_root.spotformovie);loadMovie("image.swf",_root.spotformovie); This will change dynamically without This will change dynamically without

rechanging the flash source every time rechanging the flash source every time the client requests an image.the client requests an image.

Page 18: Dynamic Flash Images: Increased Functionality and Copy Protection for Online Images Jason W. Nadal

Generated Movie CodeGenerated Movie Code<BODY bgcolor=black text=white><BODY bgcolor=black text=white><OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"

codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/scodebase="http://download.macromedia.com/pub/shockwave/cabs/flash/s wflash.cab#version=5,0,0,0" wflash.cab#version=5,0,0,0"

WIDTH=450 HEIGHT=350>WIDTH=450 HEIGHT=350> <PARAM NAME=movie <PARAM NAME=movie

VALUE="http://172.16.0.98:5080/cgi-VALUE="http://172.16.0.98:5080/cgi-bin/swiftgen.exe?sws=../php/ccsc/flashMovie/bin/swiftgen.exe?sws=../php/ccsc/flashMovie/

mainMovie.sws"> mainMovie.sws"> <PARAM NAME=quality VALUE=high> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#000000> <PARAM NAME=bgcolor VALUE=#000000> <EMBED src="http://172.16.0.98:5080/cgi-<EMBED src="http://172.16.0.98:5080/cgi-

bin/swiftgen.exe?sws=../php/ccsc/flashMovie/bin/swiftgen.exe?sws=../php/ccsc/flashMovie/mainMovie.sws" mainMovie.sws"

quality=high bgcolor=#000000 WIDTH=450 HEIGHT=350 quality=high bgcolor=#000000 WIDTH=450 HEIGHT=350 TYPE="application/x-shockwave-flash" TYPE="application/x-shockwave-flash"

PLUGINSPAGE="http://www.macromedia.com/shockwave/download/PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?index.cgi? P1_Prod_Version=ShockwaveFlash">P1_Prod_Version=ShockwaveFlash"></EMBED></EMBED>

</OBJECT></OBJECT></BODY></BODY>

Page 19: Dynamic Flash Images: Increased Functionality and Copy Protection for Online Images Jason W. Nadal

showResult.aspshowResult.asp – The Container – The Container

ShowResult.asp contains the calls to ShowResult.asp contains the calls to all of the COM+ components to do all all of the COM+ components to do all of the dirty work of creating the copy of the dirty work of creating the copy of the LAN image, the single frame of the LAN image, the single frame flash movie, and the final result flash movie, and the final result window.window.

Page 20: Dynamic Flash Images: Increased Functionality and Copy Protection for Online Images Jason W. Nadal

showResult.asp showResult.asp - Code- Code<%@ Language = "VBScript" %><%@ Language = "VBScript" %><% Response.Buffer = True %><% Response.Buffer = True %><%<%

Set myObject2 = Server.CreateObject("ServerWriteJPEG.WriteJPEG")Set myObject2 = Server.CreateObject("ServerWriteJPEG.WriteJPEG")theURL="http://172.16.0.98:5080/php/ccsc/read.php?id="theURL="http://172.16.0.98:5080/php/ccsc/read.php?id="theID = Request("id")theID = Request("id")theURL=theUrl+theIDtheURL=theUrl+theIDresult = myObject2.copyFileFromURL(theURL,"d:\xitami\webpages\php\ccsc\result = myObject2.copyFileFromURL(theURL,"d:\xitami\webpages\php\ccsc\imageTemp\image.jpg")imageTemp\image.jpg")Set myObject = Server.CreateObject("J2S.Converter.1")Set myObject = Server.CreateObject("J2S.Converter.1")myObject.FlashVersion = 5myObject.FlashVersion = 5

%>%><br><br><%<%

result = myObject.Convert("d:\xitami\webpages\php\ccsc\imagetemp\image.jpg",result = myObject.Convert("d:\xitami\webpages\php\ccsc\imagetemp\image.jpg", "d:\xitami\webpages\php\ccsc\flashMovie\image.swf")"d:\xitami\webpages\php\ccsc\flashMovie\image.swf")

%>%><br><br><iFrame src="http://172.16.0.98:5080/php/ccsc/flashMovie/showMovieSwiftGen.php" <iFrame src="http://172.16.0.98:5080/php/ccsc/flashMovie/showMovieSwiftGen.php"

width="460" height="360“ border="0" frameborder="0" scrolling=no>width="460" height="360“ border="0" frameborder="0" scrolling=no></iFrame></iFrame>

Page 21: Dynamic Flash Images: Increased Functionality and Copy Protection for Online Images Jason W. Nadal

Before - ConventionalBefore - Conventional

Pictures may be saved onto the local hard drive, and may be modified as usual JPEG files.

Page 22: Dynamic Flash Images: Increased Functionality and Copy Protection for Online Images Jason W. Nadal

The Final MovieThe Final Movie

The movie now protects the image from direct copying, thus adding a layer of protection to the original image, making it much more difficult to just copy the file.