PDA

View Full Version : Help with protecting resource doc and image files



sue
04-13-2006, 08:10 AM
Good Morning!

I am working on a project that has over 250 recipes with accompanying graphics. I am using listboxes and web object for functionality. The files are primarily html and jpgs. What I need to figure out is a way to protect the images and html pages when a user installs the program.

Currently the first listbox is populated with folder names. In that folder are recipes that will populate the second listbox when selected. When a recipe is selected in the second listbox the web object then loads the html file. Below the web object I have tabs to load the graphics for the recipe in the web object.

The application does what it is intended to do. However, I'm now ready to build the application and realize that all the htmls and images files are exposed on the user's hard drive.

What I am asking of you is a way for me to protect the files so they aren't all available for the user to use outside of the application.

I tried zipping the folders and having them unzip when the application or the page loads. But, the size of the files - particularly the image files are quite large and there's a significant delay while the files unzip - too much so for it to be a good solution. I think there is a way to only unzip the file that you need when you need it but I'm confused on how to accomplish it. Can you help me either figure out a faster way to use the zip plugin or even other solutions such as encrypting or something I don't even know? ;D

I'm looking for suggestions on methods to protect the html and image files used by the application. I'm attaching a page with one category - with one recipe - with the label and envelope graphic to demonstrate the functionality. It's a good example project for using listboxes with a web object also.

Please give me some guidance! Thank you for your help.

Sue

Roboblue
04-13-2006, 09:54 AM
It is nearly impossible to protect your project from a knowledgeable and determined person.
However, I would think that your target user probably would not be in that catagory.
I would just put the .html and image files into the Audio folder, then when building (I'm assuming you are building to a folder), just rename the resource folder to something else other than AutoPlay. On build, any file called in the project script will be zipped and renamed to *.dat (but not from the Docs folder, hence moving the files to Audio).
They are still easily viewed IF the user knows this, but most will not and probably will not go out of their way to find out.

Mina
04-13-2006, 10:23 AM
For better protection (like a project i'm building now for users to login/register at my International Services directory), I'd encrypt all my docs files, then password-zip them. Where they will be decrypted and unzipped in a temporary folder at app. runtime. This still though can be revealed.. as robo mentioned, you can never stop the users which are experienced, and determined, but you can only make it harder for them.

sue
04-13-2006, 10:44 AM
Thank you both for you suggestions! I'll be trying them today.

Sue

sue
04-13-2006, 12:09 PM
Hi again!

I did a test and moved my document folders to the audio folder and built the application with the rename resource files. But the list box does not work as intended ;(

Is it possible to rename the renamed files BACK to the original folder and file names at run time and then rename them back to the build name when closing the application so the folders and files load correctly in the listbox?

I know the zipping and unzipping works okay - except the file is so large that there is an unacceptable delay when the files are unzipping as the application opens.

Any other suggestions or something I'm not thinking of?

Thanks for any help or suggestions!!

Roboblue
04-13-2006, 12:25 PM
Assuming you replaced the AutoPlay\\Docs path to AutoPlay\\Audio in your fill list box function, then another suggestion is to use the global variable _SourceFolder.. for your paths to any file you have moved to the Audio folder.
EX:
old
"AutoPlay\\Audio\\myfile.html"
new
_SourceFolder.. "\\AutoPlay\\Audio\\myfile.html

if this doesn't work, post back with the filepaths you are using.

sue
04-13-2006, 12:45 PM
Thanks,

I think one issue is because I'm using variables instead of file names.

For example, on the page properties I'm using:

DirPaths = Folder.Find("AutoPlay\\Audio\\Modules\\Recipes", "*", false, nil);
if DirPaths then
for i, v in DirPaths do
ListBox.AddItem("listbox_Chapters",String.Replace(v, "AutoPlay\\Audio\\Modules\\Recipes\\", "", false), v);
end
end

to load the directory names into listbox 1

I'm uploading the version with the files in the audio folder. You can open and preview and it works fine. But, if I build and rename resource files and then launch the exe it doesn't populate the list box.

Thanks for your assistance!!!!

Roboblue
04-13-2006, 01:31 PM
I can't get it to work either. May have to ask the IR guys what's up.

Try this in the Page On Show event, it'll be generic and not require you to fill in string.replace.

DirPaths = Folder.Find("AutoPlay\\Audio\\Modules\\recipes", "*", true, nil);
if DirPaths then
for i, v in DirPaths do
sPath = DirPaths[1]
tPath = String.SplitPath(sPath);
ListBox.AddItem("listbox_Chapters", tPath.Filename, DirPaths[1]);
end
end

sue
04-13-2006, 01:43 PM
I submitted a support ticket this morning. I'll wait to hear what they have to say. Appreciate your help!!

Stan Hamers
04-13-2006, 01:59 PM
sorry my post was placed in this thread but it had to be a new thread.
I will try again.

Roboblue
04-14-2006, 05:14 AM
sue
By the way, remember that they can always right click on a webobject, or select text to save the content.
Here (http://www.indigorose.com/forums/showpost.php?p=80374&postcount=16) is a sample of a workaround for that. You have to always have a verticle scrollbar for it to be effective, but you can add that to your html page. Here is some info

You can add some simple styles to your site's style sheet to force a vertical scrollbar to always show and thus get rid of the page shift. The most obvious solution is to add an overflow: scroll rule to the html element. However, this rule adds a horizontal scrollbar as well, which web users definitely don't like. Here's an easy and valid way to force only the vertical scrollbar to appear, no matter what size the viewport is:

html { min-height: 100%; margin-bottom: 1px; }

This adds a tiny amount of vertical scroll — one pixel, to be exact — so users will not think they are missing any content that they need to scroll down to.

Roboblue
04-14-2006, 05:17 AM
Oh, by the way, the helper code I posted earlier is bad. Here is some good code

DirPaths = Folder.Find(_SourceFolder.. "\\AutoPlay\\Audio\\Modules\\recipes", "*", false, nil);
if DirPaths then
for i, v in DirPaths do
tPath = String.SplitPath(DirPaths[i]);
ListBox.AddItem("listbox_Chapters", tPath.Filename, DirPaths[i]);
end
end

Mina
04-14-2006, 05:32 AM
sue
By the way, remember that they can always right click on a webobject, or select text to save the content.
Here (http://www.indigorose.com/forums/showpost.php?p=80374&postcount=16) is a sample of a workaround for that. You have to always have a verticle scrollbar for it to be effective, but you can add that to your html page. Here is some info

You can add some simple styles to your site's style sheet to force a vertical scrollbar to always show and thus get rid of the page shift. The most obvious solution is to add an overflow: scroll rule to the html element. However, this rule adds a horizontal scrollbar as well, which web users definitely don't like. Here's an easy and valid way to force only the vertical scrollbar to appear, no matter what size the viewport is:

html { min-height: 100%; margin-bottom: 1px; }

This adds a tiny amount of vertical scroll — one pixel, to be exact — so users will not think they are missing any content that they need to scroll down to.

I'd avoid this workaround, since users cannot fill forms, or follow links. This method is good when viewing a 'thank-you' page, 'main page', or so.

Roboblue
04-14-2006, 05:56 AM
That's true, but the example that it was created for was a recipe app that she didn't want anyone to take her text or images from the page. Could be used for an EBook with a page turn button or slider.
For a browser, no. But it has it's uses.

sue
04-14-2006, 07:13 AM
Thanks!
Yup...you're correct this will work more as an ebook than a browser.

I'm thinking of trying to do this a little differently since the renaming resouce files doesn't work. But, I'm still missing a piece or where to do a step....

My original thought was to add all the recipes and images into a passworded zip file and unzip it when the app opened and rezip it when it closed. But, the delay was too long because of the size of the zipped file.

My newest approach is to zip up the recipes and images within a folder at a time. For instance, there would be folders like Beverages, Appetizers, etc. then inside those folders the recipes and images for the category will each be in a passworded zipped file.

When the user selects the folder from listbox 1 it would unzip the file in that folder and display the files in listbox 2. That works fine so far.

But, I don't know how or when would be the best time to rezip them.

Is there a function that would rezip the files when a new folder is selected?
1. User visits the page - clicks on beverages - passworded zip in the beverages folder is unzipped into that folder - files are displayed in listbox 2 - that's working fine in my test.
2. User then selects a second category (appetizers) - could it then zip up the files in the beverages folder and unzip the appetizers zip file? How and where would I do that at? I presume it should work in the On Select tab but I only want it to occur after the focus goes from a selected folder to a different folder - I think - or is there a better way?
3. Would it be better to do when the page closes? If so, how would I recurse through the folders to rezip the files and delete the unzipped files? If there are 40 folders with many files in each would that cause a long lag in moving to a new page?

For a rather simple application I sure have had the opportunity to learn a lot!! Thanks for all the hand holding!

Sue

Roboblue
04-14-2006, 07:47 AM
in this case, I wouldn't use the Zip actions, use the crypto (blowfish) action to encrypt each file. Then whenever the file is needed, decrypt to the user's temp folder. As soon as the file is not needed, delete it from the temp folder. this happens very fast.
But if you do use the zip, there's no reason rezip them as your zip file stays the same. Just delete the files where you unzip them to.

This is steps you need to take.
1. Either build a little batch crypto app that will encrypt all the files in a folder at one pass, or use this (http://www.durotechs.com/download/cryptodemo.zip) (it is the old IR crypto demo. But, it can only do one file at a time). Name the .enc the same as the filename, so you can use a variable throught the project created from the string.splitpath Filename action or Listbox.gettext to prevent having to type in every file name.
2. On Project Start Up create a folder in the user's temp directory like this
Folder.Create(_TempFolder.. "\\"anything"");
3. Anytime you need the file, decrypt it to the temp folder you created. if you think you wont use the file immediately, delete it. Then just decrypt it again when it's needed. Any file that is used to write to a variable, delete it in the next line of code after the variable is created.
4. When the on Project Shut Down, be sure to do a Folder.DeleteTree to get rid of the temp folder and files.

This may be redundant, but when I need to create a temp folder, I use this random Global function

function RandomNumber()
nRandom = "SRT"..Math.Random(1000000000).."";
end

Then on Project Startup I create a temp folder like this

RandomNumber()
Folder.Create(_TempFolder.. "\\"..nRandom.."");

then when I want to use that folder in the project, it'll look like this.

Crypto.BlowfishDecrypt(_SourceFolder.."\\AutoPlay\\Docs\\enc\\myfile.enc", _TempFolder.."\\"..nRandom.."\\myfile.dat", "yourpassword");
sMyFile = TextFile.ReadToString(_TempFolder.."\\"..nRandom.."\\myfile.dat");
File.Delete(_TempFolder.."\\"..nRandom.."\\myfile.dat", false, false, false, nil);


I guess it would've been faster to just create an apz, and I will later today if you want.

sue
04-14-2006, 07:55 AM
Thanks, RoboBlue!

You're an angel!!! I'll try your suggestions. If it's not too much trouble I'd love to see a sample. I've had Autoplay since version 3.0 but haven't ever tried anything with the crypto plugin - another great chance to expand my skills.

You sure are making my day!!! Thanks so much!!

Sue

Roboblue
04-14-2006, 08:57 AM
Thanks, RoboBlue!

You're an angel!!! Sue
I know it :p

After looking at your project, I thought that maybe an encrypted Zip may be the way to go, after all. Take a look at this apz and see if you want more protection. you can do it, but it's going to take a long time to code for the amount of files you have.
I moved the zip files (password is test) back to the Docs folder. I added the random temp folder function. And just to show you how it works, I put a temp folder button at the top of the app so you can see how the zip to temp folder works. you can delete that after you see what's up.
If you want to pursue the crypto, get back to us and I'll make up a similiar app to show how that would work.

sue
04-14-2006, 09:07 AM
Thank you...that was VERY helpful!

sue
04-14-2006, 09:21 AM
I'm studying your zip solution. It pointed out several things that I wasn't clear about. I think that level of protection is okay for the target. However, I still have a concern on the time it will take to unzip the files to the temp directory. When I zip up all the files and images that I'm using the delay seems a bit long. I have to do alot of optimization of the graphics I'm using but at this stage there's nearly 50 megs of content that go into the modules folder. Any possible suggestions for that? Or do you think that's just the "nature of the beast"?

Roboblue
04-14-2006, 09:59 AM
I think I know what you need. A progress bar that tells the user that it is doing "something" and that makes the wait seem less. If it just sits there while it's unzipping, it does make people nervous.

Try putting this in the Project-Actions-On Startup Event

RandomNumber()
Folder.Create(_TempFolder.. "\\"..nRandom.."");
StatusDlg.Show();
Zip.Extract("AutoPlay\\Docs\\Modules.zip", {"*.*"}, _TempFolder.. "\\"..nRandom.."", true, true, "test", ZIP_OVERWRITE_NEVER, nil);
Zip.Extract("AutoPlay\\Docs\\htmlpage.zip", {"*.*"}, _TempFolder.. "\\"..nRandom.."", true, true, "test", ZIP_OVERWRITE_NEVER, nil);
StatusDlg.Hide();

If this is better, there is a progress meter object tha can be configured that is a little prettier than the statusdialog
I don't think it's how big the Zip is, but how many files are in it.

sue
04-14-2006, 10:03 AM
I think you're right ... that did seem better. I'll take a look at the progress meter.

Thanks again!

Roboblue
04-14-2006, 10:12 AM
It's just an illusion
smoke and mirrors

sue
04-14-2006, 10:19 AM
Illusions are a good thing. Soothes the nerves sometimes.....

;D

azmanar
04-16-2006, 12:20 AM
Illusions are a good thing. Soothes the nerves sometimes.....

;D

Sue,

Have a look at this post. Good for protecting your file resources, while it is in Temp Folder.

http://www.indigorose.com/forums/showthread.php?t=15838&page=2 .

Since you're using WebObject for each Recipe Display, the pages can be copied by right-clicking on it. So still open to plagiarism.

Robo,

Can we control the right-click in any way? Or maybe use paragraphObject to display it. Would be interesting to know for building ebooks.

Combination of the crypto and Temp Close as in the post would be good. What do you think?

Roboblue
04-16-2006, 10:29 AM
you can disable the right click function of the whole page with a Page-On Mouse Button:
if e_Type == 2 then
result = Dialog.Message("Notice", "Right click has been disabled", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
end
but you can still get text by left click, drag and select, and ctr-v. I don't think you can copy an image this way tho. So you can at least protect the image.
Also in this (http://www.indigorose.com/forums/showpost.php?p=80735&postcount=11) post, there is an example on how to use On Mouse Move to disable the webobject except for the 20 pixels that the scroll bars will take up. This means either you have to always have scroll bars, or you make sure there is no content within 20 pixels of the right side or bottom.
You can also have the webobject disabled as default, and just before you load a url, enable it, then disable it on the webobjects On Loaded event. Both of these actions will also disable hyperlinks, so not useful in a browser, But maybe for ebook or information page with flash, etc.
I wouldn't use the close temp function UNLESS there is a reason that any file put there can't be immediately deleted. Otherwords, if it's sensitive project files that have to stay open while the the application runs.
On a crypto, zip, or write table to text file action, you normally only need those files long enough to write to a variable or load into an object. Once that is done, you can delete the file immediately. I think you can even unzip or decrypt an image to the temp, that once it is loaded into the image object (or webobject), it can immediately be deleted.
I am a little afraid of the close temp function because I am not sure how this would effect other applications that are using the temp to run. It may not be a problem, but until I run some tests, I am not going to use it in a permanent project. It's a good idea, tho, and if it's safe, I will use it instead of deleting temp files on the fly.
My development box is waiting parts, so I won't be able to do much for a couple of days, but I will get back to you on it.