Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss. print.
EXTENDING CRAIG BOYD'S VFPCOMPRESSION.FLL

VFPCompression.fll is a tool created by Craig Boyd to assist developers in creating a compressed file in a zip format without the need for third party software. The new version includes zip password protection. All you have to do is download the file, and unzip it, preferrably, to your “Common /Libs” directory. Below is the link:

http://www.sweetpotatosoftware.com/files/vfpcompression.zip

Later I will show you how very simple it is to call it. VFPCompression.fll offers a variety of ways to zip, unzip, open and close files or folders. However, this topic is entirely dedicated to the creation of a zip file and how to protect it further by giving the user the ability to change the password from time to time.

So let us now start the demonstration of how we can extend beyond the current limit Craig Boyd’s VFPCompression.fll.

To begin, create one commandbutton and change the caption into “Create Backup for the day”. On click event, type the following:



Local lcTodayLocal, lcTodayNet, lcCreatedZip, lcTargetFolder, lcLibraryLoc, lcReadPass, lcCurrentText, lcCurrentPassword, lnCounter

* Brief description of these variables:
* lcTodayLocal 	    = will hold the full path and filename of the current day’s zip on the local unit
* lcTodayNet  	    = the same as TodayLocal but will be used in saving a copy in the mapped drive
* lcCreatedZip 	    = is the zip path + filename, in this demonstration:  z:\data.zip
* lcTargetFolder    = the folder subject to compression
* lcLibraryLoc 	    = is where VFPCompress.fll is located
* lcReadPass 	    = holds the entire content of snaplist.txt
* lcCurrentText     = holds the per letter checking on ReadPass
* lnCounter 	    = necessary in skipping to the next letter 
* lcCurrentPassword = will hold the combined letters before the carriage Enter

* Others:
* lcSnaplist.txt    = a text file, which will hold the password.  In addition, it will also serve as a log file of all passwords used in the backup process. Snap is to break.  :  )


Always remember that before any compression job starts, you have to remind the current user to double-check if all other units utilizing your app are already closed.

If Messagebox("Warning!!! Be sure that all users with the exception of this unit have "+;
		"logged-out of the system as the system needs EXCLUSIVE use of ALL tables. "+;
		"Proceeding while other units are still using this system will result to the open "+;
		"tables be skipped or not included in the backup process. Would you like to proceed "+;
		"now?",4+48,"Very Important, please read!") = 6

    * Make sure that all databases and tables in you current session will be closed
    Close Databases All
 


For novice developers (newbies), you need to do the above. However, as Ken explains, there is a better alternative in doing backups without the need to “kick-out” any users off the system. Exact words follow:

“You can create local tables and then zip the contents of those local tables with something like this:” - Ken Murphy

SELECT * FROM MyTable1 INTO CURSOR Junk NOFILTER
SELECT MyBackup1
ZAP IN SELECT(“MyBackup1”)
APPEND FROM DBF(“Junk”)
USE IN SELECT(“Junk”)


IMHO, this is the preferred way to do it, seamless backup creation without interrupting system usage.

For simplicity, I will employ fixed folder + filename convention and the current WS cpu date here:

    m.lcTodayLocal = "c:\archive\"+Dtos(date())+".zip"
    m.lcTodayNet = "z:\archive\"+Dtos(date())+".zip"


Note: In this example, drive z: is a mapped drive on the server where my system resides. In reality, it is installed on drive d:\bbgsoft of the server, which was shared and made available to selected users. On workstations, I mapped it and assigned drive z:. Our target for compression is the DATA folder which resides inside bbgsoft folder.

    m.lcCreatedZip = "z:\data.zip"


In this example, running the backup will be done by the administrator or officer on the workstation unit he/she is using. So target folder for compression is not d:\bbgsoft\data but z:\data.

    m.lcTargetFolder = "z:\data"


Likewise, VFPCompression.fll is located in z:\ because that is where my system resides.

    lcLibraryLoc = "z:\vfpcompression.fll"


It is always imperative, for safety purposes, to check if a folder you’re planning to use exists.

    * Check if Directory exists; if not, create it
    If !Directory("c:\archive",1)
        Mkdir c:\archive
    Endif

    * Use Compression provided by Craig Boyd
    Wait "Compressing data in the background, please wait..." Window Nowait
    Set Library To (LibraryLoc)


Now, as I’ve said, I will teach you how to protect your zip file better by having the ability to change the password being used in the zip file. However, the initial question would be “How can I track down which passwords I have used during a specific backup?”. It would be very very hard indeed if you already have 5 years of backup, and have changed the password over a thousand times because you felt in a certain point in time that your password has been compromised. There is one solution, write it down to keep tab of when did you change a password and what are the files that will be affected by that. However, if you can write it down on a notebook paper, then why not just create a txt file just for that purpose? In this example, I created a text file I named snaplist.txt which I will put in z:\reports folder.
You can open it using notepad or plain edit using DOS environment. Below are examples of the password. Note that I use a combination of date and actual password. The date is very important because it will serve to remind me of the date when I changed a password:

Content of snaplist.txt:
20080403FoxiteArticle
20080402FoxiteFAQ
20080315Sandstorm36
20080222BBGSoft
20080131SweetPotato

So, with the examples above, anything between January 31, 2008 up to February 21, 2008 bear the same password which is 20080131SweetPotato. From February 22, 2008 to March 14, 2008, password used is 20080222BBGSoft. And so on…
Very important: You must terminate each new password with an Enter key because that is what I used in trapping. Also you may opt not to change password. The changing is only necessary if you think that the old one has been compromised and you decide to change it because you don’t want to give a certain person an access to new zip backup files.



    * check first if file exists
    If File("z:\reports\snaplist.txt")
        m.lcReadPass = Filetostr("z:\reports\snaplist.txt")
        m.lcCurrentPassword = ''
        m.lnCounter = 2
        m.lcCurrentText = Left(m.lcReadPass,1)
        Do While Asc(m.lcCurrentText) # 13 && ASCII 13 is Enter
            m.lcCurrentPassword = m.lcCurrentPassword + m.lcCurrentText
            m.lcCurrentText = Substr(m.lcReadPass,m.lnCounter,1)
            m.lnCounter = m.lnCounter + 1
        Enddo
        * End of extracting current password
        * In case somebody has erased content of snaplist.txt, then you must have a fallback
        * password
        If Empty(m.lcCurrentPassword)
            m.lcCurrentPassword = "Unknown2u"
        Endif
    Else
        * If file snaplist is missing, then you must have a fallback default password that is hardcoded 
        * into the system
        m.lcCurrentPassword = "Unknown2u"
    Endif
    ?ZipFolderQuick(m.lcTargetFolder,.F.,m.lcCurrentPassword)
    Set Library To 
    *** End of Craig Boyd’s compression


With VFPCompression.fll, it is designed by default to create a zip file bearing the same name of the file or folder it is instructed to zip, i.e., if the name of the file or folder subject to compression is DATA, the compressed file will be named data.zip. If you leave it that way, then you will only have ONE zip file because every time you perform the backup, it will just overwrite the previous one with a new one.

On the following commands, you will learn how to transfer the zip file you just created into a better one by automatically creating zip files bearing the current cpu date. But first you need to “arrest” or “halt” further process pending completion of the zip job. To do that, check if compression is complete by constantly checking file size. While compression is still not finished, it has a zero byte:

    Do While Fsize(m.lcCreatedZip) <= 0
    Enddo
    * Double check created zip file if it still exists
    If File(m.lcCreatedZip)
        * This will copy the instance of the zip file you just created into the 
        * mapped drive’s archive folder, plus bearing the cpu date as filename 
        Copy File(m.lcCreatedZip) To (m.lcTodayNet)      

        * This will copy the instance of the zip file you just created into the local c:\archive folder, plus 
        * bearing the cpu date as filename 
        Copy File(m.lcCreatedZip) To (m.lcTodayLocal)

        Close Databases All

        * Now delete the originally created zip file (data.zip)
        Delete File(m.lcCreatedZip)
        Wait Clear
        Messagebox(Dtos(date())+" Backup Creation is Complete!",0+64,"Backup Successfully Created!")
    Endif
Else
    Messagebox("Creation of "+Dtos(date())+" backup has been aborted!",0+48,"Oooooppssss!")
Endif
* End of extended backup process


For a more thorough reading about the subject matter, google VFPCompression.fll

ABOUT THE AUTHOR: JUN TANGUNAN

Jun Tangunan I am an Accounting graduate by profession. In my 3rd year of college, I was introduced to simple basic programming (MSDOS BASICA) where immediately I realized my real passion. But I am not used to leaving things halfway so I graduated accounting and pursue programming on my own (via reading and actual implementation) while working in a bank. Later in life, I realized that I made the right choice because my knowledge in Accounting made me a better system analyst on business software. I am a very simple man; I treat anybody as equal as long as I was shown back respect. I always go for attitude and heart. I never envy anybody; I am a very content person. I never demand recognition or fame; knowing that I am able to help somebody is enough for me. In some ways, I still think and act like a child (and sometimes I can be very naughty, so give me allowance guys whenever it happens! LOL!) and I am always proud of that. I was blessed to have the capability to make myself laugh even on simple things. My advice, always look on the brighter side of life. It will peel layers of years away from your life. Smile : )

FEEDBACK

eriq @ 4/30/2008 8:46:23 AM
hi..can u help me..can i ask for some samples..like data entry and databasing..thanks

pls send it to eriq_mimi@yahoo.com

yours,
eriq of phil

Jun Tangunan @ 5/17/2008 8:24:04 AM
Sorry for the late response eriq, I only read your request just now because I seldom went here. Anyway, it is not clear what you want. What I suggest you must do however is to start working on your project. Then if you encounter some problem, create a thread in the forum and members who can will surely help you.

It is better that way because a lot more will benefit out of it than me giving you some samples and instructions via email. I hope you understand.

sutan @ 2/20/2009 10:56:25 AM
My Server Win 2003
My Client Win 98 SE

I put Exe file and data in server that mapped drive 'G' (G:\vfp-proj)

my program :
SET LIBRARY TO LOCFILE("\vfp-proj\vfpcompression.fll")
UnzipQuick(fullpath(curdir())+"posting\brg\zip\mypo.zip", fullpath(curdir())+"posting\"+fldagen)
SET LIBRARY TO

Why i've found message "g:\vfp-proj\vfpcompression.fll is invalid"

Can you hepl me ?

Thank's

Oji Domingo @ 5/16/2009 5:25:19 AM
Hi Jun,
I've been checking your foxite articles and your programs.
Although I don't fully understand them I can tell that you are a good programmer.
I know your history. You like playing pool, binggo and jumping into countryside rivers.
I know your father and mother and your 2 brothers and your sister.
Could you help me do a program? I'll tell you the details if you call my number.
Hope you know it. If not, then check my facebook or friendster.

Hve a nice day!
Your old friend

PEDRO J GONZALEZ @ 11/1/2014 4:32:07 PM
HI i would like to have a meeting about my bussiness see if we come make it happen mail out to me po box 380160 bklyn ny 11238

MR GONZALEZ CEO @ 12/8/2014 1:09:44 AM
NEED TECH AS 84 MOTOR RUN APP FOR BUSINES AP OPP CALL ME PEDRO J GONZALEZ AS SPEEED TECH PROGRAM RUNNING

PEDRO J GONZALEZ @ 3/26/2016 5:13:38 PM
operation code on all email code seriver 200.00 run appl 23 windions



Your Name: 
Your Feedback: 

Spam Protection:
Enter the code shown: