I think that the best way to do that would just be to do some sort of file
comparrison. There are many ways you could go about this. I think the three
most common are to compare the last modified times for the files, to
compare the files' size in bytes, and then to compare a fingerprint -
usually an MD5 hash - of the files.

The GetFileInfo() function will help you for the first two, and for the MD5
hash I think the best way would be to use something like what you see in
this post:

http://www.houseoffusion.com/groups/flex/thread.cfm/threadid:1866#5804

If the files are particularly large, you may want to consider using
cfexecute with any one of the many excellent md5 implementations. If you
use shared hosting, this will likely not be an option for you as many
shared hosting providers disable cfexecute for security reasons.

On a unix install, the command should just be md5 (use the command `which
md5` to get the absolute path), and on Windows I believe you need to
install an md5 program. As always, with cfexecute there are potential
security issues that you want to take into account (e.g. make sure you
validate that you are filtering out any possible arbitrary code execution,
etc). Only use cfexecute if the files you're comparing are larger files. As
far as CFExecute goes, something like the following could be good:

<cffunction name="compareFiles" returnType="boolean">
<cfargument name="myFile1" type="string" required="true" />
<cfargument name="myFile2" type="string" required="true" />

<!--- Verifying that I got an actual file name, not an exploit. It might
also be a good idea to add code here to restrict on path --->
<cfif NOT fileExists(myFile1) OR NOT fileExists(myFile2)>
   <cfthrow message="Cannot find one or more files for comparison" />
</cfif>

<!--- I am hard-coding the path and filename of the executable --->
<cfexecute name="/sbin/md5" arguments="#myFile1#" variable="fingerprint1" />
<cfexecute name="/sbin/md5" arguments="#myFile2#" variable="fingerprint2" />

<cfreturn (fingerprint1 EQ fingerprint2) />
</cffunction>

On Mon, Jan 9, 2012 at 08:52, Mike Kear <afpwebwo...@gmail.com> wrote:

>
>  I have a webcam in the studio of our radio station, and it hangs
> sometimes.  I want to try to pin down when this happens, and send myself an
> email with the time etc so i can track down what's causing the camera to
> hang.     The webcam software uploads an image to the site every 30
> seconds,  so I figure i can track down when this hanging is occurring by
> comparing the current image with one that was uploaded 30 seconds ago.
>  When they are identical, that tells me when the camera stalled.
>
> Here's my question:   how can I use CF9  (enterprise if it makes any
> difference) to determine if the current image is identical to the one
> uploaded 30 seconds ago?
>
> Is there a CF image function or tag that will compare one image with
> another?  If not,  is there a java function or something I can use?
>
>
> Cheers
> Mike Kear
> Windsor, NSW, Australia
> Adobe Certified Advanced ColdFusion Developer
> AFP Webworks
> http://afpwebworks.com
> ColdFusion 9 Enterprise, PHP, ASP, ASP.NET hosting from AUD$15/month
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:349357
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to