1 / 22

Dynamic Flash Images:

Dynamic Flash Images:. Increased Functionality and Copy Protection for Online Images. Jason W. Nadal. The Process. Database. 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,

bonnie
Download Presentation

Dynamic Flash Images:

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. The Process

  3. Database • 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.

  4. STORE.PHP (Client View) • Adds the Image from a disk or the server’s hard drive to the database. • Data is then accessible through read.php

  5. <HTML> <HEAD><TITLE>Store binary data into SQL Database </TITLE> </HEAD> <BODY> <?php // code that will be executed if the form has been submitted: if ($submit) { // connect to the database MYSQL_CONNECT("localhost","root",""); mysql_select_db("imageDB"); $form_data_size = filesize($form_data); $form_data_name = $form_data; $data = addslashes(fread(fopen($form_data, "r"), filesize($form_data))); $result=MYSQL_QUERY("INSERT INTO testJPGs(description,bin_data, filename,filesize,filetype) ". "VALUES ('$form_description', '$data','$form_data_name', '$form_data_size','$form_data_type')"); $id= mysql_insert_id(); print "<p>This file has the following Database ID: <b>$id</b>"; ?> <img src="read.php?id=<?print"$id";?>"> <? MYSQL_CLOSE(); } else { // else show the form to submit new data: ?> <form method="get" action="store.php" enctype="multipart/form-data"> File Description:<br> <input type="text" name="form_description" size="40"> <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="1000000"> <br>File to upload/store in database:<br> <input type="file" name="form_data" size="40"> <p><input type="submit" name="submit" value="submit"> </form> <?php } ?> </BODY> </HTML> STORE.PHP (Back End)

  6. READ.PHP (Front End) • READ.PHP is available only on the local network in order to only allow access to the full JPEG version of the image for trusted machines. • READ.PHP is passed one variable: the row number of the image in the database ($id, ex. /read.php?id=4 )

  7. READ.PHP (Back End) <?php if($id) { // you may have to modify login information for your database server: @MYSQL_CONNECT("localhost","root",""); @mysql_select_db("imageDB"); $query = "select bin_data,filetype from testJPGs"; $result = @MYSQL_QUERY($query); $data = @MYSQL_RESULT($result,$id-1,"bin_data"); $type = @MYSQL_RESULT($result,$id-1,"filetype"); Header( "Content-type: $type"); echo $data; }; ?>

  8. ServerWriteJPEG.dll • No existing ATL control will let the page take an image from a URL and convert it to a single frame SWF movie. • ServerWriteJPEG.dll is a COM+ ATL control written in Java (J++) to do just that

  9. ServerWriteJPEG.dll (1) import java.awt.*; import java.awt.event.*; import java.net.*; import java.io.*; import java.applet.Applet; public class WriteJPEG { public String copyFileFromURL(String theURL, String outFile) { //takes the file at fileURL and copies it to a file //on the server's hard drive, destFile URL url; try { url = new URL(theURL); File outputFile = new File(outFile); URLConnection conn = url.openConnection(); InputStream in = conn.getInputStream(); FileOutputStream out = new FileOutputStream(outputFile); int c; while ((c = in.read()) != -1) out.write(c); in.close(); out.close(); } catch (Exception exc) {} return "Finished."; }

  10. ServerWriteJPEG.dll (2) public String copyFile(String inFile, String outFile) { //copies a file from the server to another location on the server. File inputFile = new File(inFile); File outputFile = new File(outFile); try { FileInputStream in = new FileInputStream(inputFile); FileOutputStream out = new FileOutputStream(outputFile); int c; while ((c = in.read()) != -1) out.write(c); in.close(); out.close(); } catch (Exception exc) {} return "Finished."; } }

  11. Temp Image File - Transition • A temporary image file now exists on the server. This paves the way for the file to be converted into a single frame flash image.

  12. J2S.dll - The Conversion • This DLL file is an ATL control written in C++, as part of a package to convert images to flash movies. • The component J2S.Converter.1 has the method Convert which takes 2 file arguments, input and output, and generates that SWF file on the backend when the client requests a page.

  13. Swift-Generator • Swift-Generator (swiftgen.exe) is a CGI program written in C/C++ that allows the programmer to add dynamic content to a flash movie. • Swift-Generator takes 1 argument, the location of the SWS scripting file. (ie: “/cgi/swiftgen.exe?sws=/assets/sws/movie.sws”) • SwiftGen then compiles the published SWT template file along with any assets mentioned in the SWS scripting file and creates the final compiled movie.

  14. mainMovie.sws % Jason Nadal % (c)2002 % mainMovie.sws Swift-Generator Scripting file % Script template from Template file mainMovie.swt % compiles the Template File (mainMovie.swt) with the assets into the final % result SWF movie when called with Swift-Generator CGI program. INPUT "../php/ccsc/flashMovie/mainMovie.swt" % Output for testing %OUTPUT "export.swf" % Output for CGI OUTPUT -cgi "-" % Font definitions % FONT 4 is Times New Roman (224 glyphs) SUBSTITUTE TEXT 5 { FONT 4 HEIGHT 24 KERNING 0.98 COLOR #ffff80 STRING "Image Gallery - Protected Image" }

  15. mainMovie.fla ActionScript • The main movie file contains a separate movie instance from _root which loads the generated single frame looping image movie using the command: loadMovie("image.swf",_root.spotformovie); • This will change dynamically without rechanging the flash source every time the client requests an image.

  16. Generated Movie Code <BODY bgcolor=black text=white> <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/s wflash.cab#version=5,0,0,0" WIDTH=450 HEIGHT=350> <PARAM NAME=movie VALUE="http://172.16.0.98:5080/cgi- bin/swiftgen.exe?sws=../php/ccsc/flashMovie/mainMovie.sws"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#000000> <EMBED src="http://172.16.0.98:5080/cgi- bin/swiftgen.exe?sws=../php/ccsc/flashMovie/mainMovie.sws" quality=high bgcolor=#000000 WIDTH=450 HEIGHT=350 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi? P1_Prod_Version=ShockwaveFlash"> </EMBED> </OBJECT> </BODY>

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

  18. showResult.asp - Code <%@ Language = "VBScript" %> <% Response.Buffer = True %> <% Set myObject2 = Server.CreateObject("ServerWriteJPEG.WriteJPEG") theURL="http://172.16.0.98:5080/php/ccsc/read.php?id=" theID = Request("id") theURL=theUrl+theID result = myObject2.copyFileFromURL(theURL,"d:\xitami\webpages\php\ccsc\imageTemp\image.jpg") Set myObject = Server.CreateObject("J2S.Converter.1") myObject.FlashVersion = 5 %> <br> <% result = myObject.Convert("d:\xitami\webpages\php\ccsc\imagetemp\image.jpg", "d:\xitami\webpages\php\ccsc\flashMovie\image.swf") %> <br> <iFrame src="http://172.16.0.98:5080/php/ccsc/flashMovie/showMovieSwiftGen.php" width="460" height="360“ border="0" frameborder="0" scrolling=no> </iFrame>

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

  20. The 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.

More Related