Subsribe to our RSS

latest reactions

christian louboutin shoes
With that kind of traffic you want to ad …
Rahul Anand
Thanks for the nice post. It works for m …
Serkan
thx a lot! …
msb
Thanks for above solution.There is ano …
Lori S.
FYI, I was using this successfully in CF …

Use OpenDNS

mxna feeds

cfmailparam behaviour change in CF9.01ColdFusion Job Opportunity in Houston, TXFacial Recognition in 14 Lines Of ColdFusionColdFusion UPS PackageColdFusion Job Opportunity in Arlington, VAColdFusion Job Opportunity in San Diego, CASome ColdFusionBloggers.org GuidelinesColdFusion Positions In CaliforniaListChangeDelimsunix epoch with coldfusionQuery scripting bug in Coldfusion 9Scoth On The Rock 2011 Tickets on salefoursquareCFC updated to version 1.0, now includes ColdFusion return typeFramework One Birds of a Feather session at CFUnitedWhat makes you a good ColdFusion programmer?

All files are strictly confidential: all information is classified.
© Copyright 2002 - 2010 mximize.com.
All right reserved.

MXNA webfeed

Visit Carlos Gallupa

Getting the closest locations based on Latitude / Longitude

I'm not going to explain what is being done here (SQL script) because I just don't understand. I searched a long time for this script and at the moment i'm not even sure where I got it... bottomline.. it works, and really really good.

Let's say you got the lat/lng from an http call to the Google API (small example below) and you want to get the nearest 10 other "stores" in the area around you.

<cfhttp url="http://maps.google.com/maps/geo?q=#yourpostcode-address#&gl=nl&output=csv&sensor=false&key=#yourGooglekey#" method="GET" />

<cfset aRet = listToArray(cfhttp.filecontent) />

<!--- Is it a good request and is the accuracy more then 5 (postcode level) --->
<cfif aRet[1] eq 200>
   -- call the stored procedure
   EXEC getstores @lat = #aRet[3]#
   ,@lng = #aRet[4]#
</cfif>

<!-- Save procedure in your database MSSQL 2000 and up. -->

CREATE PROCEDURE [dbo].[getstores] @lat float,  @lng float AS
DECLARE @radius float, @DegToRad float
SET @DegToRad = 57.29577951
SET @radius = 25000
SELECT TOP 10
    sto_city
    ,sto_name
    ,sto_lat
    ,sto_lng
    ,sto_street
    ,sto_postcode
    ,sto_tel
    ,sto_fax
    ,sto_email
    ,sto_url
    ,sto_supplier
    ,sto_cnt_code
    ,ROUND((ACOS((SIN(@lat/57.2958) * SIN(sto_lat/@DegToRad)) +(COS(@lat/@DegToRad) * COS(sto_lat/@DegToRad) *COS(sto_lng/@DegToRad - @lng/@DegToRad))))* 6387.7, 2) AS distance
FROM store
WHERE (sto_lat >= @lat - (@radius/111))
And (sto_lat <= @lat + (@radius/111))
AND (sto_lng >= @lng - (@radius/111))
AND (sto_lng <= @lng + (@radius/111))
AND (
     ISNUMERIC(sto_lat) = 1
    AND
    ISNUMERIC(sto_lat) = 1
)
ORDER BY distance


The distance column from the stored procedure is the total distance from the location you submitted to the Google API (postcode / address). Hope you can find a good use for this.. I did for several projects already :-)

1568 viewed | 1 opinion(s)  | del.icio.us | Digg it | Tjarko @ 23:43 cet


Get SEO keywords automatically from an article or page

I just finished a nice little function to get the "best" keywords for the page displayed in every website we build with our CMS. Below is an example, what you get is a list of the words that are mostly used in the given page and therefore the best to use as META keywords or tags in your page. At least if you like to be found on the contents of your page...

<cfsavecontent variable="txt">
A nice little piece of text with at least twice the word little in the text, and off course three times the word text ;-)
</cfsavecontent>

<cffunction name="getSEOWords" access="public" output="true">
    <cfargument name="content" required="true" type="string" />
    <cfset var lsStopWords = "stop wordlist in your language (google it)" />
    <cfset list = arrayToList(listToArray(REReplace(arguments.content, "[[:space:]]{2,}"," ", "all" ), " ")) />
    <cfset var stWords = structNew() />
    <cfset var lsTop = "" />
    <cfset var aSort = arrayNew(1) />
   
    <!--- Get a unique structure of words counted --->
    <cfloop list="#list#" index="value">
        <cfif !listFindNoCase(lsStopWords, value) && !isNumeric(value)>
            <cfset value = trim(value) />
            <cfif structKeyExists(stWords, value)>
                <cfset stWords[value] = stWords[value] + 1 />
            <cfelse>
                <cfset stWords[value] = 1 />
            </cfif>
        </cfif>
    </cfloop>
   
    <!--- Order the structure with words, first keys are the words with the most counts --->
    <cfset aSort = structSort(stWords, "numeric", "desc") />
   
    <!--- Get the first 15 words from the list, if the count is more than one. --->
    <cfloop from="1" to="15" index="i">
        <cfif stWords[aSort[i]] GT 1>
            <cfset lsTop = listAppend(lsTop, aSort[i]) />
        </cfif>
    </cfloop>

    <cfreturn lsTop />
</cffunction>

<cfoutput>
    #getSEOWords(txt)#
</cfoutput>

3569 viewed | 6 opinion(s)  | del.icio.us | Digg it | Tjarko @ 17:19 cet

Delete errors since hotfix 3 Coldfusion 8

Since the last hotfix these errors come flying by. This has always worked without any problems and all of a sudden these errors appear.

ColdFusion could not delete the file C:\somedir\somefile.jpg for an unknown reason.

Does someone know what a good solution is?? We need to delete the file after some file operations. These are not big files, maybe 1MB at the most. Seems like a timing or locking issue but it always worked until last week when we installed the hotfix.

3056 viewed | 1 opinion(s)  | del.icio.us | Digg it | Tjarko @ 12:13 cet

Strange font behaviour with cfdocument pdf

When we run a scheduled task that produces PDF files with cfdocument we get randomly PDF files with the complete text but in a strange font, or something?? (see example)

After searching on the internet I cannot find anything that explains this.... Does anyone have a clue on what's going on with these PDF files?? We produce hundreds a day without a problem but every now and then we get jibberish like below. It's becoming a real problem because these are contracts with people who are getting or wanting a home and can't see what's in the letter.

The PDF document that looks strange

If someone from Adobe sees this, I still have the other issue posted on this blog with PDF files (and more people do) fix it please!! We pay you for it!!

Thanks in advance if you can point me in the right direction.

2640 viewed | Your opinion...  | del.icio.us | Digg it | Tjarko @ 9:48 cet

Simple file upload protection

These days it's all over the news that there is a new security bug in ColdFusion regarding file uploads and spoofing the mimetype. We use the bit of code below to simply check for the combination contenttype / extension. If the combination does not match... bye bye

<cfset stAllow = structNew() />
<cfset stAllow["image"] = "jpg,gif,png,jpeg" />
<cfset stAllow["file"] = "doc,xls,pdf,rtf,txt" />
<cfset stAllow["application"] = "zip,rar,doc,pdf,xls,ppt,swf,flv,txt" />
<cfset stAllow["audio"] = "mp3,mpa,mpg,ra,wav" />
<cfset stAllow["video"] = "mov,qt,mpeg,mp3,mpa,mpg" />
<cfset stAllow["text"] = "txt,htm,html,log,css" />

<cfif structKeyExists(stAllow, file.contenttype) && listFindNoCase(stAllow[file.contenttype],file.serverfileext)>
    You may pass...
<cfelse>
    You will NOT pass!!!
    <!--- Delete the file or something --->
</cfif>


This works in a simple yet very effective way. People could still upload a file that is a .cfm and rename it to .gif but for the webserver it will be an image file.. no harm there. You can change the structure to your liking offcourse.

Some other tips are to only set "read" rights to the upload dir, place an application.cfm file with a <cfabort> tag in the upload dir (if it's accessible from the web)

3297 viewed | 2 opinion(s)  | del.icio.us | Digg it | Tjarko @ 12:27 cet